CNLiveMineButtonCell.m 2.36 KB
//
//  CNLiveMineButtonCell.m
//  CNLiveMineModule
//
//  Created by 153993236@qq.com on 11/12/2019.
//  Copyright © 2019 153993236@qq.com. All rights reserved.
//

#import "CNLiveMineButtonCell.h"
#import <Masonry/Masonry.h>
#import "QMUIKit.h"
#import "CNLiveCategory.h"
#import "CNLiveBaseKit.h"
#import "CNLiveMineModel.h"

@interface CNLiveMineButtonCell()
@property (nonatomic, strong) UIImageView *image;
@property (nonatomic, strong) UILabel *title;

@end

@implementation CNLiveMineButtonCell
#pragma mark - 生命周期
- (id)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.contentView.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:self.image];
        [self.contentView addSubview:self.title];
    }
    return self;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    [_image mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left);
        make.right.equalTo(self.contentView.mas_right);
        make.top.equalTo(self.contentView.mas_top);
        make.height.offset(self.frame.size.height*2/3.0);
        
    }];
    [_title mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.image.mas_bottom);
        make.left.equalTo(self.image.mas_left);
        make.right.equalTo(self.image.mas_right);
        make.bottom.equalTo(self.contentView.mas_bottom);

    }];
    
}

#pragma mark - 数据
- (void)setModel:(CNLiveMineButtonModel *)model{
    UIImage *xw_image = [self getImageWithImageName:model.image bundleName:@"CNLiveMineModule" targetClass:[self class]];
    _image.image = xw_image;
    _title.text = model.title;
    _title.font = UIFontCNMake(12.0);
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

#pragma mark - 懒加载
- (UIImageView *)image{
    if (!_image) {
        _image = [[UIImageView alloc] init];
        _image.contentMode = UIViewContentModeCenter;
    }
    return _image;
}

- (UILabel *)title {
    if (!_title) {
        _title = [[UILabel alloc] init];
        _title.userInteractionEnabled = YES;
        _title.numberOfLines = 1;
        _title.lineBreakMode = NSLineBreakByTruncatingTail;
        _title.textColor = [UIColor blackColor];
        _title.textAlignment = NSTextAlignmentCenter;
        _title.font = UIFontCNMake(12.0);
    }
    return _title;
}

@end