123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- //
- // YOUPAILZLiveInviteCell.m
- // TIANYAN
- //
- // Created by CY on 2021/5/28.
- // Copyright © 2021 leo. All rights reserved.
- //
- #import "YOUPAILZLiveInviteCell.h"
- #import "YOUPAILZLevelView.h"
- @interface YOUPAILZLiveInviteCell ()
- @property (nonatomic, weak) UIImageView *youpaipavatarImgV; // 头像
- @property (nonatomic, weak) UILabel *youpaipnicknameL; // 昵称
- @property (nonatomic, weak) UIButton *youpaipinviteBtn; // 邀请按钮
- @property (nonatomic, weak) YOUPAILZLevelView *youpaiplevelView;
- @property (nonatomic, weak) YOUPAILZLiveInviteModel *youpaipmodel;
- @end
- @implementation YOUPAILZLiveInviteCell
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
- if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
- self.selectionStyle = UITableViewCellSelectionStyleNone;
- self.backgroundColor = [UIColor clearColor];
- [self youpaifinitUI];
- }
- return self;
- }
- - (void)youpaifinitUI{
- UIImageView *youpaipavatarImgV = [[UIImageView alloc] init];
- youpaipavatarImgV.contentMode = UIViewContentModeScaleAspectFill;
- youpaipavatarImgV.layer.cornerRadius = 20.0f;
- youpaipavatarImgV.clipsToBounds = YES;
- youpaipavatarImgV.layer.borderColor = HexColorFromRGB(0x9F9DA5).CGColor;
- youpaipavatarImgV.layer.borderWidth = 1.0f;
- [self.contentView addSubview:youpaipavatarImgV];
- self.youpaipavatarImgV = youpaipavatarImgV;
- [youpaipavatarImgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.offset(19.0f);
- make.centerY.equalTo(self.contentView.mas_centerY);
- make.size.mas_offset(CGSizeMake(40.0f, 40.0f));
- }];
-
- UIButton *youpaipinviteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- youpaipinviteBtn.titleLabel.font = LCFont12;
- [youpaipinviteBtn setTitle:@"邀请" forState:UIControlStateNormal];
- [youpaipinviteBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- youpaipinviteBtn.layer.cornerRadius = 11.0f;
- youpaipinviteBtn.clipsToBounds = YES;
- [youpaipinviteBtn addTarget:self action:@selector(youpaifinviteBtnClick) forControlEvents:UIControlEventTouchUpInside];
- [self.contentView addSubview:youpaipinviteBtn];
- self.youpaipinviteBtn = youpaipinviteBtn;
- [youpaipinviteBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.offset(-14.0f);
- make.size.mas_offset(CGSizeMake(56.0f, 22.0f));
- make.centerY.equalTo(self.contentView.mas_centerY);
- }];
-
- UILabel *youpaipnicknameL = [[UILabel alloc] init];
- youpaipnicknameL.font = LCFont14;
- youpaipnicknameL.textColor = [UIColor whiteColor];
- [self.contentView addSubview:youpaipnicknameL];
- self.youpaipnicknameL = youpaipnicknameL;
- [youpaipnicknameL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(youpaipavatarImgV.mas_right).offset(8.0f);
- make.top.bottom.offset(0.0f);
- }];
-
- YOUPAILZLevelView *youpaiplevelView = [[YOUPAILZLevelView alloc] init];
- [self.contentView addSubview:youpaiplevelView];
- self.youpaiplevelView = youpaiplevelView;
- [youpaiplevelView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(youpaipnicknameL.mas_right).offset(5.0f);
- make.centerY.equalTo(youpaipnicknameL);
- }];
- }
- - (void)youpaifreloadWithModel:(YOUPAILZLiveInviteModel *)model type:(LZLiveInviteType)type{
- self.youpaipmodel = model;
-
- [self.youpaipavatarImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:model.youpaipanchor_avatar]];
- if ([model.youpaipstatus isEqual:@"over"]) {
- [self.youpaipinviteBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(56.0f, 22.0f) FromColors:@[HexColorFromRGB(0x4F4B5B),HexColorFromRGB(0x4F4B5B)] ByGradientType:GradientLeftToRight] forState:UIControlStateNormal];
- self.youpaipinviteBtn.userInteractionEnabled = NO;
- }else{
- [self.youpaipinviteBtn setBackgroundImage:[self youpaifinviteBtnBackgoundImageWithType:type] forState:UIControlStateNormal];
- self.youpaipinviteBtn.userInteractionEnabled = YES;
- }
- self.youpaipnicknameL.text = model.youpaipanchor_name;
- [self.youpaiplevelView youpaifreloadWithIcon:model.youpaipgrade.youpaipimg1 iconWidth:model.youpaipgrade.youpaipicon_width bgImg:model.youpaipgrade.youpaipimg2 bgImgWidth:model.youpaipgrade.youpaipicon1_width levelName:model.youpaipgrade.youpaipgrade_name level:model.youpaipgrade.youpaipgrade];
- [self.youpaiplevelView mas_updateConstraints:^(MASConstraintMaker *make) {
- make.size.mas_offset(self.youpaiplevelView.mj_size);
- }];
- }
- - (void)youpaifinviteBtnClick{
- if (self.youpaipinviteBlock != nil) {
- self.youpaipinviteBlock(self.youpaipmodel);
- }
- }
- - (UIImage *)youpaifinviteBtnBackgoundImageWithType:(LZLiveInviteType)type{
- if (type == LZLiveInviteTypePK) {
- return [LCTools ColorImage:CGSizeMake(56.0f, 22.0f) FromColors:@[HexColorFromRGB(0x75DFFF),HexColorFromRGB(0x0038FF)] ByGradientType:GradientLeftToRight];
- }else{
- return [LCTools ColorImage:CGSizeMake(56.0f, 22.0f) FromColors:@[HexColorFromRGB(0xFF3BDC),HexColorFromRGB(0xFC2F55)] ByGradientType:GradientLeftToRight];
- }
- }
- @end
|