YOUPAILZRecommendAnchorCell.m 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. //
  2. // YOUPAILZRecommendAnchorCell.m
  3. // VQU
  4. //
  5. // Created by CY on 2021/6/11.
  6. // Copyright © 2021 leo. All rights reserved.
  7. //
  8. #import "YOUPAILZRecommendAnchorCell.h"
  9. @interface YOUPAILZRecommendAnchorCell ()
  10. @property (nonatomic, weak) UIImageView *youpaipavatarImgV;
  11. @property (nonatomic, weak) UILabel *youpaipnicknameL;
  12. @property (nonatomic, weak) UILabel *youpaipnumberL;
  13. @end
  14. @implementation YOUPAILZRecommendAnchorCell
  15. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  16. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  17. [self youpaifinitUI];
  18. self.backgroundColor = [UIColor clearColor];
  19. self.selectionStyle = UITableViewCellSelectionStyleNone;
  20. }
  21. return self;
  22. }
  23. - (void)youpaifinitUI{
  24. UIImageView *youpaipavatarImgV = [[UIImageView alloc] init];
  25. youpaipavatarImgV.contentMode = UIViewContentModeScaleAspectFill;
  26. youpaipavatarImgV.layer.cornerRadius = 5.0f;
  27. youpaipavatarImgV.clipsToBounds = YES;
  28. [self.contentView addSubview:youpaipavatarImgV];
  29. self.youpaipavatarImgV = youpaipavatarImgV;
  30. [youpaipavatarImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  31. make.left.offset(5.0f);
  32. make.right.bottom.offset(-5.0f);
  33. make.top.offset(0.0f);
  34. }];
  35. UILabel *youpaipnicknameL = [[UILabel alloc] init];
  36. youpaipnicknameL.textColor = [UIColor whiteColor];
  37. youpaipnicknameL.font = LCFont(10.0f);
  38. [self.contentView addSubview:youpaipnicknameL];
  39. self.youpaipnicknameL = youpaipnicknameL;
  40. [youpaipnicknameL mas_makeConstraints:^(MASConstraintMaker *make) {
  41. make.left.offset(7.0f);
  42. make.bottom.offset(-6.0f);
  43. }];
  44. UILabel *numberL = [[UILabel alloc] init];
  45. numberL.textColor = [[UIColor whiteColor] colorWithAlphaComponent:0.9f];
  46. numberL.font = LCFont(10.0f);
  47. [self.contentView addSubview:numberL];
  48. self.youpaipnumberL = numberL;
  49. [numberL mas_makeConstraints:^(MASConstraintMaker *make) {
  50. make.right.offset(-7.0f);
  51. make.bottom.offset(-7.0f);
  52. }];
  53. }
  54. - (void)youpaifreloadWithModel:(YOUPAILZLiveListItemModel *)model{
  55. [self.youpaipavatarImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:model.youpaipcover_img]];
  56. [self youpaifsetupShadowWithText:model.youpaipanchor_name view:self.youpaipnicknameL];
  57. [self youpaifsetupShadowWithText:[NSString stringWithFormat:@"%@人在看",model.youpaiptotal_viewers] view:self.youpaipnumberL];
  58. }
  59. - (void)youpaifsetupShadowWithText:(NSString *)text view:(UILabel *)view{
  60. NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc]initWithString:text];
  61. NSShadow *shadow = [[NSShadow alloc]init];
  62. // shadow.shadowBlurRadius = 1.0;
  63. shadow.shadowOffset = CGSizeMake(1, 1.5f);
  64. shadow.shadowColor = [HexColorFromRGB(0x000000) colorWithAlphaComponent:0.2f];
  65. [attributedString addAttribute:NSShadowAttributeName value:shadow range:NSMakeRange(0, text.length)];
  66. view.attributedText = attributedString;
  67. }
  68. @end