《省钱达人》与《猎豆优选》UI相同版。域名tbk

DRMineAdView.m 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. //
  2. // DRMineAdView.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/6/6.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "DRMineAdView.h"
  9. @interface DRMineAdView ()
  10. {
  11. UIImageView *_imageView;
  12. }
  13. @end
  14. @implementation DRMineAdView
  15. - (instancetype)initWithFrame:(CGRect)frame {
  16. self = [super initWithFrame:frame];
  17. if (self) {
  18. self.backgroundColor = [UIColor clearColor];
  19. self.clipsToBounds = YES;
  20. [self initSubViews];
  21. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction)];
  22. [self addGestureRecognizer:tap];
  23. }
  24. return self;
  25. }
  26. - (void)initSubViews {
  27. _imageView = [[UIImageView alloc] init];
  28. _imageView.userInteractionEnabled = YES;
  29. _imageView.clipsToBounds = YES;
  30. _imageView.layer.masksToBounds = YES;
  31. _imageView.contentMode = UIViewContentModeScaleAspectFill;
  32. _imageView.backgroundColor = [UIColor whiteColor];
  33. _imageView.layer.cornerRadius = 6;
  34. [self addSubview:_imageView];
  35. [_imageView mas_makeConstraints:^(MASConstraintMaker *make) {
  36. make.left.right.top.mas_equalTo(0);
  37. make.bottom.mas_equalTo(-5);
  38. }];
  39. }
  40. - (void)setModel:(AdPopModel *)model {
  41. _model = model;
  42. [_imageView sd_setImageWithURL:[NSURL URLWithString:model.img] placeholderImage:nil];
  43. }
  44. - (void)tapAction {
  45. if (self.tapAdBlock) {
  46. self.tapAdBlock(_model);
  47. }
  48. }
  49. - (void)closeAction {
  50. if (self.closeBlock) {
  51. self.closeBlock();
  52. }
  53. }
  54. @end