| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- //
- // MOLiveMsgSystemTipCell.m
- // MiMoLive
- //
- // Created by SuperC on 2024/2/17.
- //
- #import "MOLiveMsgSystemTipCell.h"
- @implementation MOLiveMsgSystemTipCell
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
- self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
- if (self != nil) {
- self.contentView.transform = CGAffineTransformMakeScale(1, -1);
- self.backgroundColor = [UIColor clearColor];
- self.selectionStyle = UITableViewCellSelectionStyleNone;
-
- [self setupUI];
- }
-
- return self;
- }
- - (void)setupUI{
- [self.contentView addSubview:self.bgView];
- [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.contentView).offset(MOBgViewOffSet);
- make.right.equalTo(self.contentView).offset(-MOBgViewOffSet);
- make.top.equalTo(self.contentView).offset(MOBgViewOffSet);
- make.bottom.equalTo(self.contentView).offset(-MOBgViewOffSet);
- }];
- self.bgView.layer.cornerRadius = 10.0;
-
- [self.bgView addSubview:self.contentTextView];
- [self.contentTextView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.bgView).offset(0.0);
- make.right.equalTo(self.bgView).offset(0.0);
- make.centerY.equalTo(self.bgView);
- make.height.equalTo(@16.0);
- }];
- }
- - (void)awakeFromNib {
- [super awakeFromNib];
- // Initialization code
- }
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- // Configure the view for the selected state
- }
- - (void)setCellModel:(MORtmEntity *)cellModel{
- _cellModel = cellModel;
-
- MORtmJosnEntity *jsonEntity = (MORtmJosnEntity *)cellModel.data;
-
- NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:jsonEntity.content];
- [attributedString addAttribute:NSForegroundColorAttributeName value:kBaseTextHightlightColor_1 range:NSMakeRange(0, [attributedString length])];
- // 设置字体大小的属性
- [attributedString addAttribute:NSFontAttributeName value:MOTextLabelFont range:NSMakeRange(0, attributedString.length)];
- self.contentTextView.attributedText = attributedString;
-
- CGFloat contentHeight = cellModel.cellHeight;
- if(contentHeight < MORtmContentMixHeight){
- contentHeight = MORtmContentMixHeight;
- }
- [self.contentTextView mas_updateConstraints:^(MASConstraintMaker *make) {
- make.height.equalTo(@(contentHeight));
- }];
- }
- #pragma mark - Lazy
- - (UIView *)bgView
- {
- if (_bgView == nil)
- {
- _bgView = [UIView new];
- _bgView.backgroundColor = MONormalBgViewColor;
- }
- return _bgView;
- }
- - (MOMsgContentTextView *)contentTextView{
- if(!_contentTextView){
- _contentTextView = [MOMsgContentTextView new];
- _contentTextView.backgroundColor = [UIColor clearColor];
- _contentTextView.textContainerInset = UIEdgeInsetsMake(MOContentBaseTopSpcing, MOContentBaseLeftSpacing, MOContentBaseBottomSpcing, MOContentBaseRightSpacing);//UITextView原本文字距离左右有间距,设置负数消除边距
- _contentTextView.editable = NO;
- _contentTextView.scrollEnabled = NO;//防止滑出屏幕又滑入时有时单行文字消失
- _contentTextView.userInteractionEnabled = NO;
- _contentTextView.textColor = [MOTools colorWithHexString:@"#FFFFFF" alpha:1.0];
- }
- return _contentTextView;
- }
- @end
|