// // LDTodayAdView.m // YouHuiProject // // Created by 小花 on 2018/9/6. // Copyright © 2018年 kuxuan. All rights reserved. // #import "LDTodayAdView.h" @interface LDTodayAdView () { UIImageView *_imageView; } @end @implementation LDTodayAdView - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { self.backgroundColor = [UIColor whiteColor]; self.layer.cornerRadius = 6; self.clipsToBounds = YES; [self initSubViews]; UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction)]; [self addGestureRecognizer:tap]; } return self; } - (void)initSubViews { // CGFloat width = SCREEN_MUTI > 1? 314 : Fitsize(314); // CGFloat height = SCREEN_MUTI > 1? 72 : Fitsize(72); _imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.width, (self.width)*200/750)]; _imageView.userInteractionEnabled = YES; _imageView.clipsToBounds = YES; _imageView.layer.masksToBounds = YES; _imageView.centerX = self.width/2; _imageView.backgroundColor = [UIColor clearColor]; _imageView.contentMode = UIViewContentModeScaleAspectFill; [self addSubview:_imageView]; // UIButton *close = [[UIButton alloc] initWithFrame:CGRectMake(self.width-30-5, 0, 30, 30)]; // close.centerY = _imageView.centerY; // [close setImage:[UIImage imageNamed:@"close_ad"] forState:UIControlStateNormal]; // [close addTarget:self action:@selector(closeAction) forControlEvents:UIControlEventTouchUpInside]; // [self addSubview:close]; } - (void)setModel:(AdPopModel *)model { [_imageView sd_setImageWithURL:[NSURL URLWithString:model.img] completed:nil]; } - (void)tapAction { if (self.tapAdBlock) { self.tapAdBlock(); } } @end