YOUPAILZLiveFollowCell.m 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. //
  2. // YOUPAILZLiveFollowCell.m
  3. // TIANYAN
  4. //
  5. // Created by CY on 2021/5/26.
  6. // Copyright © 2021 leo. All rights reserved.
  7. //
  8. #import "YOUPAILZLiveFollowCell.h"
  9. @interface YOUPAILZLiveFollowCell ()
  10. @property (nonatomic, strong) YOUPAILZLiveModel *youpaipmodel;
  11. @property (nonatomic, strong) NSIndexPath *youpaipindexPath;
  12. @property (nonatomic, weak) UIImageView *youpaipavatarImgV;
  13. @end
  14. @implementation YOUPAILZLiveFollowCell
  15. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  16. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  17. self.transform = CGAffineTransformMakeRotation(M_PI);
  18. self.selectionStyle = UITableViewCellSelectionStyleNone;
  19. self.backgroundColor = [UIColor clearColor];
  20. [self youpaifinitUI];
  21. }
  22. return self;
  23. }
  24. - (void)youpaifinitUI{
  25. UIView *bgV = [[UIView alloc] init];
  26. bgV.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3f];
  27. bgV.layer.cornerRadius = 17.5f;
  28. bgV.clipsToBounds = YES;
  29. [self.contentView addSubview:bgV];
  30. [bgV mas_makeConstraints:^(MASConstraintMaker *make) {
  31. make.left.offset(5.0f);
  32. make.top.offset(6.0f);
  33. make.bottom.offset(0.0f);
  34. }];
  35. UIImageView *youpaipavatarImgV = [[UIImageView alloc] init];
  36. youpaipavatarImgV.contentMode = UIViewContentModeScaleAspectFill;
  37. youpaipavatarImgV.layer.cornerRadius = 16.5f;
  38. youpaipavatarImgV.clipsToBounds = YES;
  39. [bgV addSubview:youpaipavatarImgV];
  40. self.youpaipavatarImgV = youpaipavatarImgV;
  41. [youpaipavatarImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  42. make.left.top.offset(1.0f);
  43. make.bottom.offset(-1.0f);
  44. make.size.mas_offset(CGSizeMake(33.0f, 33.0f));
  45. }];
  46. UIButton *youpaipfollowBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  47. [youpaipfollowBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(34.0f, 23.0f) FromColors:@[HexColorFromRGB(0xE85DF7),HexColorFromRGB(0xFF3DA5)] ByGradientType:GradientLeftToRight] forState:UIControlStateNormal];
  48. youpaipfollowBtn.layer.cornerRadius = 11.5f;
  49. youpaipfollowBtn.clipsToBounds = YES;
  50. youpaipfollowBtn.titleLabel.font = LCFont(12.0f);
  51. [youpaipfollowBtn setTitle:@"关注" forState:UIControlStateNormal];
  52. [youpaipfollowBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  53. [youpaipfollowBtn addTarget:self action:@selector(youpaiffollowBtnClick) forControlEvents:UIControlEventTouchUpInside];
  54. [bgV addSubview:youpaipfollowBtn];
  55. [youpaipfollowBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  56. make.right.offset(-4.0f);
  57. make.size.mas_offset(CGSizeMake(34.0f, 23.0f));
  58. make.centerY.equalTo(bgV.mas_centerY);
  59. }];
  60. UILabel *contentL = [[UILabel alloc] init];
  61. contentL.font = LCBoldFont(14.0f);
  62. contentL.textColor = [UIColor whiteColor];
  63. contentL.text = @"点关注 不迷路";
  64. [bgV addSubview:contentL];
  65. [contentL mas_makeConstraints:^(MASConstraintMaker *make) {
  66. make.left.equalTo(youpaipavatarImgV.mas_right).offset(4.0f);
  67. make.right.equalTo(youpaipfollowBtn.mas_left).offset(-4.0f);
  68. make.top.bottom.offset(0.0f);
  69. }];
  70. }
  71. - (void)youpaiffollowBtnClick{
  72. if (self.youpaipfollowBlock != nil) {
  73. self.youpaipfollowBlock(self.youpaipmodel, self.youpaipindexPath);
  74. }
  75. }
  76. - (void)youpaifreloadWithModel:(YOUPAILZLiveModel *)model indexPath:(NSIndexPath *)indexPath{
  77. self.youpaipmodel = model;
  78. self.youpaipindexPath = indexPath;
  79. [self.youpaipavatarImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:model.youpaipuser_info.youpaipavatar]];
  80. }
  81. @end