猎豆优选

LDSearchSpecialView.m 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //
  2. // LDSearchSpecialView.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/12/6.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "LDSearchSpecialView.h"
  9. @interface LDSearchSpecialView ()
  10. @property (nonatomic, strong) UIImageView *imgView;
  11. @end
  12. @implementation LDSearchSpecialView
  13. - (instancetype)initWithFrame:(CGRect)frame
  14. {
  15. self = [super initWithFrame:frame];
  16. if (self) {
  17. [self addSubview:self.imgView];
  18. [self.imgView mas_makeConstraints:^(MASConstraintMaker *make) {
  19. make.edges.mas_equalTo(UIEdgeInsetsMake(0, 0, 0, 0));
  20. }];
  21. }
  22. return self;
  23. }
  24. - (void)setModel:(AdPopModel *)model {
  25. _model = model;
  26. [self.imgView sd_setImageWithURL:[NSURL URLWithString:model.img]];
  27. }
  28. - (void)tapImage {
  29. if (self.tapImgBlock) {
  30. self.tapImgBlock(self.model);
  31. }
  32. }
  33. - (UIImageView *)imgView {
  34. if (!_imgView) {
  35. _imgView = [[UIImageView alloc] init];
  36. _imgView.contentMode = UIViewContentModeScaleAspectFill;
  37. _imgView.clipsToBounds = YES;
  38. _imgView.userInteractionEnabled = YES;
  39. _imgView.backgroundColor = [UIColor yhGrayColor];
  40. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImage)];
  41. [_imgView addGestureRecognizer:tap];
  42. }
  43. return _imgView;
  44. }
  45. @end