| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- //
- // MOLiveMsgFanClubTipCell.m
- // MiMoLive
- //
- // Created by SuperC on 2025/6/23.
- //
- #import "MOLiveMsgFanClubTipCell.h"
- @interface MOLiveMsgFanClubTipCell ()
- @property (nonatomic, strong) UILabel *tipLab;
- @property (nonatomic, strong) UIImageView *tagImgView;
- /** 气泡的点击手势(可以根据需要将这个手势从视图中移除或禁止) */
- @property (nonatomic, strong, readonly) UITapGestureRecognizer *bubbleTapGestureRecognizer;
- @end
- @implementation MOLiveMsgFanClubTipCell
- - (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.width.equalTo(@(MOBgViewMaxWidth));
- 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(MOContentLeftAndRighSpacing);
- make.right.equalTo(self.bgView).offset(-MOContentLeftAndRighSpacing);
- make.height.equalTo(@16.0);
- }];
-
- [self.bgView addSubview:self.tagImgView];
- [self.tagImgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.bgView).offset(-14);
- make.width.height.equalTo(@12.0);
- make.bottom.equalTo(self.bgView).offset(-7);
- }];
-
- [self.bgView addSubview:self.tipLab];
- [self.tipLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.bgView).offset(MOContentLeftAndRighSpacing);
- make.centerY.equalTo(self.tagImgView);
- make.right.equalTo(self.tagImgView.mas_left).offset(-2);
- make.height.equalTo(@18.0);
- }];
-
- self.bgView.userInteractionEnabled = YES;
- _bubbleTapGestureRecognizer = [UITapGestureRecognizer new];
- [_bubbleTapGestureRecognizer addTarget:self action:@selector(bubbleTapped:)];
- _bubbleTapGestureRecognizer.delegate = self;
- [self.bgView addGestureRecognizer:self.bubbleTapGestureRecognizer];
- }
- - (void)bubbleTapped:(UITapGestureRecognizer *)recognizer
- {
- MOLogV(@"触发了点击");
- self.cellTapBlock ? self.cellTapBlock(self.cellModel) : nil;
- }
- - (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 *titleAttr = [MOTextTools creteTextWith:cellModel];
- self.contentTextView.attributedText = titleAttr;
-
- CGFloat width = cellModel.contentWidth + MOContentLeftAndRighSpacing * 2.0 + MOContentOffSet * 3.0 ;
- if(width > MOBgViewMaxWidth){
- width = MOBgViewMaxWidth;
- }
-
- if(width < MOBgViewMinWidth){
- width = MOBgViewMinWidth;
- }
- [self.bgView mas_updateConstraints:^(MASConstraintMaker *make) {
- make.width.equalTo(@(width));
- }];
- }
- #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;
- }
- - (UILabel *)tipLab{
- if(!_tipLab){
- _tipLab = [[UILabel alloc] init];
- _tipLab.textColor = [MOTools colorWithHexString:@"#FFE254" alpha:1.0];
- _tipLab.font = [MOTextTools mediumFont:13.0];
- _tipLab.textAlignment = NSTextAlignmentLeft;
- _tipLab.text = NSLocalString(@"mimo_2_live_rtm_fan_club_tip_3");
- }
- return _tipLab;
- }
- - (UIImageView *)tagImgView{
- if(!_tagImgView){
- _tagImgView = [[UIImageView alloc] init];
- _tagImgView.image = [UIImage imageNamed:@"v_2_new_yellow_right"];
- _tagImgView.contentMode = UIViewContentModeScaleAspectFit;
- }
- return _tagImgView;
- }
- @end
|