Files
mier_ios/SweetParty/主类/RCMic/Room/礼物连击-新/TDGiftAnimationCell.m
2025-08-11 10:43:19 +08:00

180 lines
5.3 KiB
Objective-C

//
// TDGiftAnimationCell.m
// liveDemo
//
// Created by tuandai on 2017/4/21.
// Copyright © 2017年 tuandai. All rights reserved.
//
#import "TDGiftAnimationCell.h"
#import "TCCustomMessageModel.h"
#define kSpecialTextColor HEXCOLOR(0xeeff5f)
@interface TDGiftAnimationCell ()
@property (nonatomic, strong) UILabel *numLable;
@property (nonatomic, strong) UIImageView *iconView;
@property (nonatomic, strong) UIImageView *giftImg;
@property (nonatomic, strong) UIView *bgView;
@property (nonatomic, strong) UILabel *userName;
@property (nonatomic, strong) UILabel *tips;
@property (nonatomic, strong) UILabel *multipleLab;//暴击倍数
@end
@implementation TDGiftAnimationCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
self.selectionStyle = UITableViewCellSelectionStyleNone;
self.backgroundColor = self.contentView.backgroundColor = kClearColor;
}
return self;
}
-(void)setGiftModel:(TCCustomMessageModel *)giftModel {
_giftModel = giftModel;
[self.iconView sd_setImageWithURL:[NSURL URLWithString:giftModel.imUserIconUrl] placeholderImage:kDefaultUserIcon];
self.userName.text = giftModel.imUserName;
self.tips.text = giftModel.msg;
[self.giftImg sd_setImageWithURL:[NSURL URLWithString:giftModel.giftUrl]];
if (giftModel.win_multiple > 0) {
self.multipleLab.text = [NSString stringWithFormat:@"暴击%ld倍", giftModel.win_multiple];
}else {
self.multipleLab.text = @"";
}
self.numLable.text = [NSString stringWithFormat:@"x%zd",_giftModel.combo];
// //动画
// if (_giftModel.isComboed) {
// [self anima:_giftModel.combo];
// }else {
// self.numLable.text = [NSString stringWithFormat:@"X%zd",_giftModel.combo];
// }
}
//- (void)anima:(NSInteger)num {
// [self.numLable anima:num];
//}
#pragma mark - 懒加载
-(UIView *)bgView {
if (!_bgView) {
_bgView = [UIView new];
_bgView.backgroundColor = HEXCOLORA(0xFFFFFF, 0.2);
_bgView.layer.cornerRadius = 30;
[self.contentView addSubview:_bgView];
[_bgView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(15);
make.centerY.mas_equalTo(0);
make.width.mas_equalTo(240);
make.height.mas_equalTo(60);
}];
}
return _bgView;
}
-(UILabel *)numLable {
if (!_numLable) {
_numLable = [UILabel new];
_numLable.textColor = kSpecialTextColor;
_numLable.font = [UIFont systemFontOfSize:50 weight:UIFontWeightBold];
[self.contentView addSubview:_numLable];
[_numLable mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self.contentView);
make.left.mas_equalTo(self.bgView.mas_right).mas_offset(10);
}];
}
return _numLable;
}
-(UIImageView *)giftImg {
if (!_giftImg) {
_giftImg = [UIImageView new];
[self.bgView addSubview:_giftImg];
[_giftImg mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(0);
make.right.mas_equalTo(self.bgView).offset(-10);
make.width.height.mas_equalTo(35);
}];
}
return _giftImg;
}
-(UIImageView *)iconView {
if (!_iconView) {
_iconView = [UIImageView new];
_iconView.layer.cornerRadius = 25;
_iconView.layer.masksToBounds = YES;
_iconView.contentMode = UIViewContentModeScaleAspectFill;
[self.bgView addSubview:_iconView];
[_iconView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(5);
make.centerY.mas_equalTo(self.bgView);
make.width.height.mas_equalTo(50);
}];
}
return _iconView;
}
-(UILabel *)tips {
if (!_tips) {
_tips = [UILabel new];
_tips.font = [UIFont systemFontOfSize:13 weight:UIFontWeightMedium];
_tips.textColor = kSpecialTextColor;
[self.bgView addSubview:_tips];
[_tips mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.userName.mas_bottom).offset(5.0);
make.left.equalTo(self.userName);
}];
}
return _tips;
}
-(UILabel *)multipleLab {
if (!_multipleLab) {
_multipleLab = [UILabel new];
_multipleLab.font = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium];
_multipleLab.textColor = kSpecialTextColor;
[self.bgView addSubview:_multipleLab];
[_multipleLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(-2);
make.right.mas_equalTo(-15);
}];
}
return _multipleLab;
}
-(UILabel *)userName {
if (!_userName) {
_userName = [UILabel new];
_userName.font = [UIFont systemFontOfSize:15 weight:UIFontWeightMedium];
_userName.textColor = kWhiteColor;
[self.bgView addSubview:_userName];
[_userName mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(12);
make.left.equalTo(self.iconView.mas_right).offset(6);
make.right.equalTo(self.giftImg.mas_left).offset(-6);
}];
}
return _userName;
}
@end