// // YOUPAILZRecommendAnchorCell.m // VQU // // Created by CY on 2021/6/11. // Copyright © 2021 leo. All rights reserved. // #import "YOUPAILZRecommendAnchorCell.h" @interface YOUPAILZRecommendAnchorCell () @property (nonatomic, weak) UIImageView *youpaipavatarImgV; @property (nonatomic, weak) UILabel *youpaipnicknameL; @property (nonatomic, weak) UILabel *youpaipnumberL; @end @implementation YOUPAILZRecommendAnchorCell - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { [self youpaifinitUI]; self.backgroundColor = [UIColor clearColor]; self.selectionStyle = UITableViewCellSelectionStyleNone; } return self; } - (void)youpaifinitUI{ UIImageView *youpaipavatarImgV = [[UIImageView alloc] init]; youpaipavatarImgV.contentMode = UIViewContentModeScaleAspectFill; youpaipavatarImgV.layer.cornerRadius = 5.0f; youpaipavatarImgV.clipsToBounds = YES; [self.contentView addSubview:youpaipavatarImgV]; self.youpaipavatarImgV = youpaipavatarImgV; [youpaipavatarImgV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(5.0f); make.right.bottom.offset(-5.0f); make.top.offset(0.0f); }]; UILabel *youpaipnicknameL = [[UILabel alloc] init]; youpaipnicknameL.textColor = [UIColor whiteColor]; youpaipnicknameL.font = LCFont(10.0f); [self.contentView addSubview:youpaipnicknameL]; self.youpaipnicknameL = youpaipnicknameL; [youpaipnicknameL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(7.0f); make.bottom.offset(-6.0f); }]; UILabel *numberL = [[UILabel alloc] init]; numberL.textColor = [[UIColor whiteColor] colorWithAlphaComponent:0.9f]; numberL.font = LCFont(10.0f); [self.contentView addSubview:numberL]; self.youpaipnumberL = numberL; [numberL mas_makeConstraints:^(MASConstraintMaker *make) { make.right.offset(-7.0f); make.bottom.offset(-7.0f); }]; } - (void)youpaifreloadWithModel:(YOUPAILZLiveListItemModel *)model{ [self.youpaipavatarImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:model.youpaipcover_img]]; [self youpaifsetupShadowWithText:model.youpaipanchor_name view:self.youpaipnicknameL]; [self youpaifsetupShadowWithText:[NSString stringWithFormat:@"%@人在看",model.youpaiptotal_viewers] view:self.youpaipnumberL]; } - (void)youpaifsetupShadowWithText:(NSString *)text view:(UILabel *)view{ NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc]initWithString:text]; NSShadow *shadow = [[NSShadow alloc]init]; // shadow.shadowBlurRadius = 1.0; shadow.shadowOffset = CGSizeMake(1, 1.5f); shadow.shadowColor = [HexColorFromRGB(0x000000) colorWithAlphaComponent:0.2f]; [attributedString addAttribute:NSShadowAttributeName value:shadow range:NSMakeRange(0, text.length)]; view.attributedText = attributedString; } @end