YOUPAILZMyMusicCell.m 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. //
  2. // YOUPAILZMyMusicCell.m
  3. // YOUQU
  4. //
  5. // Created by CY on 2021/12/11.
  6. // Copyright © 2021 MS. All rights reserved.
  7. //
  8. #import "YOUPAILZMyMusicCell.h"
  9. #import "LOTAnimationView.h"
  10. @interface YOUPAILZMyMusicCell ()
  11. @property (nonatomic,weak) LOTAnimationView *youpaipanimationView;
  12. @property (nonatomic, weak) UILabel *youpaipsongNameL; // 歌曲名称
  13. @property (nonatomic, weak) UILabel *youpaipsingerL; // 演唱者
  14. @property (nonatomic, weak) UIButton *youpaipmoreBtn; // 更多
  15. @property (nonatomic, strong) YOUPAILZMusicListItemModel *youpaipmodel;
  16. @end
  17. @implementation YOUPAILZMyMusicCell
  18. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  19. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  20. self.selectionStyle = UITableViewCellSelectionStyleNone;
  21. self.backgroundColor = [UIColor clearColor];
  22. [self youpaifinitUI];
  23. }
  24. return self;
  25. }
  26. - (void)youpaifinitUI{
  27. UIButton *youpaipmoreBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  28. [youpaipmoreBtn setImage:[UIImage imageNamed:@"vqu_image_music_more"] forState:UIControlStateNormal];
  29. [youpaipmoreBtn addTarget:self action:@selector(youpaifmoreBtnClick) forControlEvents:UIControlEventTouchUpInside];
  30. [self.contentView addSubview:youpaipmoreBtn];
  31. self.youpaipmoreBtn = youpaipmoreBtn;
  32. [youpaipmoreBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  33. make.right.offset(-14.0f);
  34. make.size.mas_offset(CGSizeMake(25.0f, 25.0f));
  35. make.centerY.equalTo(self.contentView);
  36. }];
  37. UILabel *youpaipsongNameL = [[UILabel alloc] init];
  38. youpaipsongNameL.font = LCFont(14.0f);
  39. youpaipsongNameL.textColor = [UIColor whiteColor];
  40. [self.contentView addSubview:youpaipsongNameL];
  41. self.youpaipsongNameL = youpaipsongNameL;
  42. [youpaipsongNameL mas_makeConstraints:^(MASConstraintMaker *make) {
  43. make.left.offset(40.0f);
  44. make.top.offset(14.0f);
  45. make.right.equalTo(youpaipmoreBtn.mas_left).offset(-14.0f);
  46. }];
  47. UILabel *youpaipsingerL = [[UILabel alloc] init];
  48. youpaipsingerL.font = LCFont(11.0f);
  49. youpaipsingerL.textColor = HexColorFromRGB(0x9F9DA5);
  50. [self.contentView addSubview:youpaipsingerL];
  51. self.youpaipsingerL = youpaipsingerL;
  52. [youpaipsingerL mas_makeConstraints:^(MASConstraintMaker *make) {
  53. make.top.equalTo(youpaipsongNameL.mas_bottom).offset(6.0f);
  54. make.left.offset(40.0f);
  55. make.right.equalTo(youpaipmoreBtn.mas_left).offset(-14.0f);
  56. }];
  57. LOTAnimationView *youpaipanimationView = [LOTAnimationView animationWithFilePath:[[NSBundle mainBundle] pathForResource:@"vqu_image_music_play_animation" ofType:@"json"]];
  58. youpaipanimationView.loopAnimation = YES;
  59. youpaipanimationView.hidden = YES;
  60. youpaipanimationView.contentMode = UIViewContentModeScaleAspectFill;
  61. [youpaipanimationView play];
  62. [self addSubview:youpaipanimationView];
  63. self.youpaipanimationView = youpaipanimationView;
  64. [youpaipanimationView mas_makeConstraints:^(MASConstraintMaker *make) {
  65. make.left.offset(16.0f);
  66. make.centerY.equalTo(self.contentView);
  67. make.size.mas_offset(CGSizeMake(12.0f, 12.0f));
  68. }];
  69. }
  70. - (void)youpaifmoreBtnClick{
  71. if (self.moreBtnClickBlock != nil) {
  72. self.moreBtnClickBlock(self.youpaipmodel);
  73. }
  74. }
  75. -(void)youpaifreloadWithModel:(YOUPAILZMusicListItemModel *)model{
  76. self.youpaipmodel = model;
  77. self.youpaipsongNameL.text = model.youpaipname;
  78. self.youpaipanimationView.hidden = !model.youpaipisPlay;
  79. // NSMutableString *artistStr = [NSMutableString string];
  80. // for (YOUPAILZMusicArtistModel *artistModel in model.youpaipartist) {
  81. // [artistStr appendString:artistModel.youpaipname];
  82. // if (artistModel != model.youpaipartist.lastObject) {
  83. // [artistStr appendString:@"/"];
  84. // }
  85. // }
  86. // if (artistStr.length != 0 && model.youpaipalbumName.length != 0) {
  87. // [artistStr appendString:@" - "];
  88. // }
  89. // [artistStr appendString:model.youpaipalbumName];
  90. self.youpaipsingerL.text = model.youpaipsinger;
  91. }
  92. @end