口袋优选

LDTodayAdView.m 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. //
  2. // LDTodayAdView.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/9/6.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "LDTodayAdView.h"
  9. @interface LDTodayAdView ()
  10. {
  11. UIImageView *_imageView;
  12. }
  13. @end
  14. @implementation LDTodayAdView
  15. - (instancetype)initWithFrame:(CGRect)frame {
  16. self = [super initWithFrame:frame];
  17. if (self) {
  18. self.backgroundColor = [UIColor whiteColor];
  19. self.layer.cornerRadius = 6;
  20. self.clipsToBounds = YES;
  21. [self initSubViews];
  22. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction)];
  23. [self addGestureRecognizer:tap];
  24. }
  25. return self;
  26. }
  27. - (void)initSubViews {
  28. // CGFloat width = SCREEN_MUTI > 1? 314 : Fitsize(314);
  29. // CGFloat height = SCREEN_MUTI > 1? 72 : Fitsize(72);
  30. _imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.width, (self.width)*200/750)];
  31. _imageView.userInteractionEnabled = YES;
  32. _imageView.clipsToBounds = YES;
  33. _imageView.layer.masksToBounds = YES;
  34. _imageView.centerX = self.width/2;
  35. _imageView.backgroundColor = [UIColor clearColor];
  36. _imageView.contentMode = UIViewContentModeScaleAspectFill;
  37. [self addSubview:_imageView];
  38. // UIButton *close = [[UIButton alloc] initWithFrame:CGRectMake(self.width-30-5, 0, 30, 30)];
  39. // close.centerY = _imageView.centerY;
  40. // [close setImage:[UIImage imageNamed:@"close_ad"] forState:UIControlStateNormal];
  41. // [close addTarget:self action:@selector(closeAction) forControlEvents:UIControlEventTouchUpInside];
  42. // [self addSubview:close];
  43. }
  44. - (void)setModel:(AdPopModel *)model {
  45. [_imageView sd_setImageWithURL:[NSURL URLWithString:model.img] completed:nil];
  46. }
  47. - (void)tapAction {
  48. if (self.tapAdBlock) {
  49. self.tapAdBlock();
  50. }
  51. }
  52. @end