123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- //
- // HSQContainerImageCell.m
- // YouHuiProject
- //
- // Created by 小花 on 2018/12/28.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "HSQContainerImageCell.h"
- @interface HSQContainerImageCell ()
- @property (nonatomic, strong) UIImageView *imgView;
- @property (nonatomic, strong) UIButton *selectedBtn;
- @end
- @implementation HSQContainerImageCell
- - (instancetype)initWithFrame:(CGRect)frame
- {
- self = [super initWithFrame:frame];
- if (self) {
- [self initSubViews];
- }
- return self;
- }
- - (void)initSubViews {
- [self.contentView addSubview:self.imgView];
- [self.contentView addSubview:self.selectedBtn];
- [self.contentView addSubview:self.qrImgLabel];
-
- [self.imgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.mas_equalTo(UIEdgeInsetsMake(0, 0, 0, 0));
- }];
-
- [self.selectedBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.right.mas_equalTo(0);
- make.width.height.mas_equalTo(40);
- }];
-
- [self.qrImgLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.bottom.mas_equalTo(0);
- make.height.mas_equalTo(28);
- }];
-
- }
- - (void)selectAction {
- if (self.selectBlock) {
- self.selectBlock();
- }
- }
- - (void)setModel:(HSQShareImageCellModel *)model {
- if (model.imgUrl) {
- [self.imgView sd_setFadeImageWithURL:[NSURL URLWithString:model.imgUrl] placeholderImage:nil options:0 progress:nil completed:nil];
- }else {
- if (model.shareImg) {
- self.imgView.image = model.shareImg;
- }else {
- self.imgView.image = nil;
- }
- }
-
- self.selectedBtn.selected = model.isSelected;
- }
- - (UIImageView *)imgView {
- if (!_imgView) {
- _imgView = [[UIImageView alloc] init];
- _imgView.contentMode = UIViewContentModeScaleAspectFit;
- _imgView.backgroundColor = [UIColor whiteColor];
- }
- return _imgView;
- }
- - (UIButton *)selectedBtn {
- if (!_selectedBtn) {
- _selectedBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [_selectedBtn setImage:[UIImage imageNamed:@"cell_sel_n"] forState:UIControlStateNormal];
- [_selectedBtn setImage:[UIImage imageNamed:@"cell_sel_s"] forState:UIControlStateSelected];
- [_selectedBtn addTarget:self action:@selector(selectAction) forControlEvents:UIControlEventTouchUpInside];
- }
- return _selectedBtn;
- }
- - (UILabel *)qrImgLabel {
- if (!_qrImgLabel) {
- _qrImgLabel = [[UILabel alloc] init];
- _qrImgLabel.backgroundColor = [UIColor YHColorWithHex:0xFF891A];
- _qrImgLabel.textColor = [UIColor whiteColor];
- _qrImgLabel.textAlignment = NSTextAlignmentCenter;
- _qrImgLabel.font = [UIFont systemFontOfSize:13];
- _qrImgLabel.text = @"二维码推广图";
- }
- return _qrImgLabel;
- }
- @end
|