YOUPAILZGiftNoticeCell.m 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. //
  2. // YOUPAILZGiftNoticeCell.m
  3. // MSYOUPAI
  4. //
  5. // Created by CY on 2022/2/28.
  6. // Copyright © 2022 MS. All rights reserved.
  7. //
  8. #import "YOUPAILZGiftNoticeCell.h"
  9. @interface YOUPAILZGiftNoticeCell ()
  10. @property (nonatomic, weak) UIImageView *youpaipformAvatarImgV; // 发送者头像
  11. @property (nonatomic, weak) UILabel *youpaipformNicknameL; // 发送者昵称
  12. @property (nonatomic, weak) UIImageView *youpaipgiftImgV; // 礼物图片
  13. @property (nonatomic, weak) UILabel *youpaipgiftCountL; // 礼物数量
  14. @property (nonatomic, weak) UIImageView *youpaiptoAvatarImgV; // 接受者头像
  15. @property (nonatomic, weak) UILabel *youpaiptoNicknameL; // 接受者昵称
  16. @end
  17. @implementation YOUPAILZGiftNoticeCell
  18. - (instancetype)initWithFrame:(CGRect)frame{
  19. if (self = [super initWithFrame: frame]) {
  20. [self youpaifinitUI];
  21. }
  22. return self;
  23. }
  24. - (void)youpaifinitUI{
  25. UIView *fromBgView = [[UIView alloc] init];
  26. [self.contentView addSubview:fromBgView];
  27. [fromBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  28. make.left.offset(6.0f);
  29. make.centerY.equalTo(self.contentView);
  30. make.width.offset(44.0f);
  31. }];
  32. UIImageView *youpaipformAvatarImgV = [[UIImageView alloc] init];
  33. youpaipformAvatarImgV.layer.cornerRadius = 14.0f;
  34. youpaipformAvatarImgV.layer.borderColor = [UIColor whiteColor].CGColor;
  35. youpaipformAvatarImgV.layer.borderWidth = 1.0f;
  36. youpaipformAvatarImgV.clipsToBounds = YES;
  37. youpaipformAvatarImgV.contentMode = UIViewContentModeScaleAspectFill;
  38. [fromBgView addSubview:youpaipformAvatarImgV];
  39. self.youpaipformAvatarImgV = youpaipformAvatarImgV;
  40. [youpaipformAvatarImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  41. make.top.offset(0.0f);
  42. make.centerX.equalTo(fromBgView);
  43. make.size.mas_offset(CGSizeMake(28.0f, 28.0f));
  44. }];
  45. UILabel *youpaipformNicknameL = [[UILabel alloc] init];
  46. youpaipformNicknameL.font = LCFont(10.0f);
  47. youpaipformNicknameL.textColor = LZ475A7DColor;
  48. youpaipformNicknameL.textAlignment = NSTextAlignmentCenter;
  49. [fromBgView addSubview:youpaipformNicknameL];
  50. self.youpaipformNicknameL = youpaipformNicknameL;
  51. [youpaipformNicknameL mas_makeConstraints:^(MASConstraintMaker *make) {
  52. make.left.right.offset(0.0f);
  53. make.bottom.offset(0.0f);
  54. make.height.offset(12.0f);
  55. make.top.equalTo(youpaipformAvatarImgV.mas_bottom).offset(2.0f);
  56. }];
  57. UILabel *youpaifgiveL = [[UILabel alloc] init];
  58. youpaifgiveL.font = LCBoldFont(11.0f);
  59. youpaifgiveL.textColor = LZ475A7DColor;
  60. youpaifgiveL.text = @"赠送";
  61. [self.contentView addSubview:youpaifgiveL];
  62. [youpaifgiveL mas_makeConstraints:^(MASConstraintMaker *make) {
  63. make.left.equalTo(fromBgView.mas_right).offset(4.0f);
  64. make.centerY.equalTo(youpaipformAvatarImgV);
  65. }];
  66. UIImageView *youpaipgiftImgV = [[UIImageView alloc] init];
  67. youpaipgiftImgV.contentMode = UIViewContentModeScaleAspectFill;
  68. [self.contentView addSubview:youpaipgiftImgV];
  69. self.youpaipgiftImgV = youpaipgiftImgV;
  70. [youpaipgiftImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  71. make.centerY.equalTo(youpaipformAvatarImgV);
  72. make.left.equalTo(youpaifgiveL.mas_right).offset(4.0f);
  73. make.size.mas_offset(CGSizeMake(38.0f, 38.0f));
  74. }];
  75. UILabel *youpaipgiftCountL = [[UILabel alloc] init];
  76. youpaipgiftCountL.font = LCBoldFont(11.0f);
  77. youpaipgiftCountL.textColor = LZ475A7DColor;
  78. youpaipgiftCountL.text = @"x1";
  79. [self.contentView addSubview:youpaipgiftCountL];
  80. self.youpaipgiftCountL = youpaipgiftCountL;
  81. [youpaipgiftCountL mas_makeConstraints:^(MASConstraintMaker *make) {
  82. make.left.equalTo(youpaipgiftImgV.mas_right).offset(4.0f);
  83. make.centerY.equalTo(youpaipformAvatarImgV);
  84. }];
  85. UIView *toBgView = [[UIView alloc] init];
  86. [self.contentView addSubview:toBgView];
  87. [toBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  88. make.left.equalTo(youpaipgiftCountL.mas_right).offset(4.0f);
  89. make.centerY.equalTo(self.contentView);
  90. make.width.offset(44.0f);
  91. }];
  92. UIImageView *youpaiptoAvatarImgV = [[UIImageView alloc] init];
  93. youpaiptoAvatarImgV.layer.cornerRadius = 14.0f;
  94. youpaiptoAvatarImgV.layer.borderColor = [UIColor whiteColor].CGColor;
  95. youpaiptoAvatarImgV.layer.borderWidth = 1.0f;
  96. youpaiptoAvatarImgV.clipsToBounds = YES;
  97. youpaiptoAvatarImgV.contentMode = UIViewContentModeScaleAspectFill;
  98. [toBgView addSubview:youpaiptoAvatarImgV];
  99. self.youpaiptoAvatarImgV = youpaiptoAvatarImgV;
  100. [youpaiptoAvatarImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  101. make.top.offset(0.0f);
  102. make.centerX.equalTo(toBgView);
  103. make.size.mas_offset(CGSizeMake(28.0f, 28.0f));
  104. }];
  105. UILabel *youpaiptoNicknameL = [[UILabel alloc] init];
  106. youpaiptoNicknameL.font = LCFont(10.0f);
  107. youpaiptoNicknameL.textColor = LZ475A7DColor;
  108. youpaiptoNicknameL.textAlignment = NSTextAlignmentCenter;
  109. [toBgView addSubview:youpaiptoNicknameL];
  110. self.youpaiptoNicknameL = youpaiptoNicknameL;
  111. [youpaiptoNicknameL mas_makeConstraints:^(MASConstraintMaker *make) {
  112. make.left.right.offset(0.0f);
  113. make.bottom.offset(0.0f);
  114. make.height.offset(12.0f);
  115. make.top.equalTo(youpaiptoAvatarImgV.mas_bottom).offset(2.0f);
  116. }];
  117. }
  118. - (void)youpaifreloadWithModel:(YOUPAILZHomeTVModel *)model{
  119. [self.youpaipformAvatarImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:model.youpaipfrom_avatar]];
  120. [self.youpaiptoAvatarImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:model.youpaipto_avatar]];
  121. self.youpaipformNicknameL.text = model.youpaipfrom_nickname;
  122. self.youpaiptoNicknameL.text = model.youpaipto_nickname;
  123. self.youpaipgiftCountL.text = [NSString stringWithFormat:@"x%@",model.youpaipgift_count];
  124. [self.youpaipgiftImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:model.youpaipgift_img]];
  125. }
  126. @end