// // KBChildPageAdView.m // YouHuiProject // // Created by 小花 on 2018/10/16. // Copyright © 2018年 kuxuan. All rights reserved. // #import "KBChildPageAdView.h" @interface KBChildPageAdView () @property (nonatomic, strong) UIImageView *imgView; @end @implementation KBChildPageAdView - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { self.clipsToBounds = YES; self.backgroundColor = [UIColor whiteColor]; self.layer.cornerRadius = Fitsize(8); self.imgView = [[UIImageView alloc] initWithFrame:self.bounds]; self.imgView.clipsToBounds = YES; self.imgView.userInteractionEnabled = YES; self.imgView.contentMode = UIViewContentModeScaleAspectFill; [self addSubview:self.imgView]; self.autoresizingMask = YES; UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAdAction)]; [self.imgView addGestureRecognizer:tap]; self.imgView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; } return self; } - (void)tapAdAction { if (self.tapAdBlock) { self.tapAdBlock(self.adModel); } } - (void)setAdModel:(AdPopModel *)adModel { _adModel = adModel; [self.imgView sd_setImageWithURL:[NSURL URLWithString:adModel.img]]; } @end