// // SPSBMineMessageTableViewCell.m // 我的社保 // // Created by shanp on 2021/5/21. // #import "SPSBMineMessageTableViewCell.h" #import "SPSBUIGeneralHeader.h" #import #import "SPSBMineMessageModel.h" @interface SPSBMineMessageTableViewCell () { UILabel *_timeLabel; UILabel *_titleLabel; UILabel *_contentLabel; UIView *_contentBgView; } @end @implementation SPSBMineMessageTableViewCell + (SPSBMineMessageTableViewCell *)creatFirstCell { SPSBMineMessageTableViewCell *cell = [[self alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil]; UIView *bannerBg = UIView.new; bannerBg.backgroundColor = spsb_FFFFFF_color(1.f); [bannerBg setLayerCornerRadius:4 clipToBounds:true]; [cell->_contentBgView addSubview:bannerBg]; [bannerBg makeConstraints:^(JXHConstraintMaker *make) { make.top.and.leading.and.trailing.equalTo(0); make.height.equalTo((jxh_screenWidth() - 30) * 0.35 + 20); }]; UIImageView *banner = [[UIImageView alloc] initWithImage:jxh_getImage(notice_banner)]; [bannerBg addSubview:banner]; [banner makeConstraints:^(JXHConstraintMaker *make) { make.top.and.left.and.right.equalTo(0); make.height.equalTo((jxh_screenWidth() - 30) * 0.35); }]; [cell->_titleLabel remakeConstraints:^(JXHConstraintMaker *make) { make.leading.equalTo(20); make.trailing.equalTo(-20); make.top.equalTo(bannerBg.bottom); }]; return cell; } - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (!self) return nil; self.selectionStyle = UITableViewCellSelectionStyleNone; self.backgroundColor = spsb_F5F5F5_color(); _timeLabel = [UILabel convenienceWithFont:spsb_font(13) text:@"" textColor:spsb_FFFFFF_color(1.f) textAlignment:NSTextAlignmentCenter]; [_timeLabel setLayerCornerRadius:12 clipToBounds:true]; _timeLabel.backgroundColor = spsb_000000_color(0.15); [self.contentView addSubview:_timeLabel]; [_timeLabel makeConstraints:^(JXHConstraintMaker *make) { make.centerX.equalTo(self.contentView); make.top.equalTo(0); make.size.equalTo(CGSizeMake(150, 25)); }]; _contentBgView = UIView.new; _contentBgView.backgroundColor = spsb_FFFFFF_color(1.f); [self.contentView addSubview:_contentBgView]; [_contentBgView makeConstraints:^(JXHConstraintMaker *make) { make.top.equalTo(40); make.leading.equalTo(15); make.bottom.equalTo(-30); make.trailing.equalTo(-15); }]; _titleLabel = [UILabel convenienceWithFont:spsb_semiboldFont(17) text:@"" textColor:spsb_333333_color()]; [_contentBgView addSubview:_titleLabel]; [_titleLabel makeConstraints:^(JXHConstraintMaker *make) { make.leading.equalTo(20); make.trailing.equalTo(-20); make.top.equalTo(21); }]; _contentLabel = [UILabel convenienceWithFont:spsb_font(16) text:@"" textColor:spsb_666666_color()]; [_contentBgView addSubview:_contentLabel]; [_contentLabel makeConstraints:^(JXHConstraintMaker *make) { make.leading.equalTo(20); make.trailing.equalTo(-20); make.top.equalTo(self->_titleLabel.bottom).offset(15); make.bottom.equalTo(-24); }]; return self; } - (void)reloadData:(SPSBMineMessageModel *)data { _timeLabel.text = data.spsb_time; [_titleLabel setAttributedStringWithText:data.spsb_title lineSpacing:3]; [_contentLabel setAttributedStringWithText:data.spsb_content lineSpacing:4]; } - (void)layoutSubviews { [super layoutSubviews]; [_contentBgView.layer setShadowWithOffset:(CGSize){0, 2} alpha:0.03 blur:4 spread:0 color:spsb_FFFFFF_color(1.f) cornerRadius:4 pathRect:(CGRect){0, 0, jxh_screenWidth() - 30, jxh_viewHeight(self.contentView) - 70}]; } @end