1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- //
- // LDChildPageAdView.m
- // YouHuiProject
- //
- // Created by 小花 on 2018/12/6.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "LDChildPageAdView.h"
- @interface LDChildPageAdView ()
- @property (nonatomic, strong) UIImageView *imgView;
- @end
- @implementation LDChildPageAdView
- - (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
|