| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- //
- // YRMsgMainCell.m
- // UU_Ent
- //
- // Created by liujl on 2019/4/29.
- // Copyright © 2019 UAS. All rights reserved.
- //
- #import "YRMsgMainCell.h"
- @interface YRMsgMainCell()
- @property(strong,nonatomic)UIImageView *iconView;
- @property(strong,nonatomic)UILabel *remindLabel;
- @property(strong,nonatomic)UILabel *titleLabel;
- @property(strong,nonatomic)UILabel *subTitLabel;
- @end
- @implementation YRMsgMainCell
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(nullable NSString *)reuseIdentifier{
-
- if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
-
- [self setUpUI];
-
- }
-
- return self;
- }
- -(void)setUpUI{
-
- [self.contentView addSubview:self.iconView];
- [self.iconView addSubview:self.remindLabel];
- [self.contentView addSubview:self.titleLabel];
- [self.contentView addSubview:self.subTitLabel];
-
- [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.top.equalTo(self.contentView).offset(16);
- make.left.equalTo(self.contentView).offset(18);
- make.bottom.equalTo(self.contentView).offset(-16);
- make.width.mas_equalTo(34);
-
- }];
-
- [self.remindLabel mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.top.equalTo(self.iconView).offset(-8);
- make.right.equalTo(self.iconView).offset(8);
- make.width.height.mas_equalTo(16);
-
- }];
-
- [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.contentView).offset(14);
- make.left.equalTo(self.iconView.mas_right).offset(10);
- make.height.mas_equalTo(20);
- make.right.equalTo(self.contentView).offset(-20);
- }];
-
- [self.subTitLabel mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.top.equalTo(self.titleLabel.mas_bottom).offset(6);
- make.height.mas_greaterThanOrEqualTo(@10);
- make.left.equalTo(self.iconView.mas_right).offset(10);
- make.right.equalTo(self.contentView).offset(-20);
- }];
-
-
- }
- -(void)setModel:(YRMsgMainModel *)model{
-
- _model = model;
-
- self.iconView.image = [UIImage imageNamed:model.icon];
- self.titleLabel.text = model.name;
- self.subTitLabel.text = @"这是副标题";
- if (model.remindCount > 0) {
-
- self.remindLabel.hidden = NO;
- self.remindLabel.text = [NSString stringWithFormat:@"%ld",(long)model.remindCount];
-
- }else{
-
- self.remindLabel.hidden = YES;
-
- }
- }
- #pragma mark - lazy
- -(UIImageView *)iconView{
-
- if (!_iconView) {
-
- _iconView = [[UIImageView alloc]init];
-
-
- }
-
- return _iconView;
- }
- -(UILabel *)remindLabel{
-
- if (!_remindLabel) {
-
- _remindLabel = [UILabel new];
- _remindLabel.font = [UIFont systemFontOfSize:9];
- _remindLabel.textAlignment = NSTextAlignmentCenter;
- _remindLabel.textColor = [UIColor whiteColor];
- _remindLabel.backgroundColor = [UIColor redColor];
- _remindLabel.layer.cornerRadius = 8;
- _remindLabel.layer.masksToBounds = YES;
-
- }
-
- return _remindLabel;
- }
- -(UILabel *)titleLabel{
-
- if (!_titleLabel) {
-
- _titleLabel = [UILabel new];
-
-
- }
-
- return _titleLabel;
- }
- -(UILabel *)subTitLabel{
-
- if (!_subTitLabel) {
-
- _subTitLabel = [UILabel new];
- _subTitLabel.font = [UIFont systemFontOfSize:11];
- _subTitLabel.textColor = [UIColor grayColor];
-
- }
-
- return _subTitLabel;
- }
- @end
|