// // YOUPAILZMyMusicCell.m // YOUQU // // Created by CY on 2021/12/11. // Copyright © 2021 MS. All rights reserved. // #import "YOUPAILZMyMusicCell.h" #import "LOTAnimationView.h" @interface YOUPAILZMyMusicCell () @property (nonatomic,weak) LOTAnimationView *youpaipanimationView; @property (nonatomic, weak) UILabel *youpaipsongNameL; // 歌曲名称 @property (nonatomic, weak) UILabel *youpaipsingerL; // 演唱者 @property (nonatomic, weak) UIButton *youpaipmoreBtn; // 更多 @property (nonatomic, strong) YOUPAILZMusicListItemModel *youpaipmodel; @end @implementation YOUPAILZMyMusicCell - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { self.selectionStyle = UITableViewCellSelectionStyleNone; self.backgroundColor = [UIColor clearColor]; [self youpaifinitUI]; } return self; } - (void)youpaifinitUI{ UIButton *youpaipmoreBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [youpaipmoreBtn setImage:[UIImage imageNamed:@"vqu_image_music_more"] forState:UIControlStateNormal]; [youpaipmoreBtn addTarget:self action:@selector(youpaifmoreBtnClick) forControlEvents:UIControlEventTouchUpInside]; [self.contentView addSubview:youpaipmoreBtn]; self.youpaipmoreBtn = youpaipmoreBtn; [youpaipmoreBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.right.offset(-14.0f); make.size.mas_offset(CGSizeMake(25.0f, 25.0f)); make.centerY.equalTo(self.contentView); }]; UILabel *youpaipsongNameL = [[UILabel alloc] init]; youpaipsongNameL.font = LCFont(14.0f); youpaipsongNameL.textColor = [UIColor whiteColor]; [self.contentView addSubview:youpaipsongNameL]; self.youpaipsongNameL = youpaipsongNameL; [youpaipsongNameL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(40.0f); make.top.offset(14.0f); make.right.equalTo(youpaipmoreBtn.mas_left).offset(-14.0f); }]; UILabel *youpaipsingerL = [[UILabel alloc] init]; youpaipsingerL.font = LCFont(11.0f); youpaipsingerL.textColor = HexColorFromRGB(0x9F9DA5); [self.contentView addSubview:youpaipsingerL]; self.youpaipsingerL = youpaipsingerL; [youpaipsingerL mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(youpaipsongNameL.mas_bottom).offset(6.0f); make.left.offset(40.0f); make.right.equalTo(youpaipmoreBtn.mas_left).offset(-14.0f); }]; LOTAnimationView *youpaipanimationView = [LOTAnimationView animationWithFilePath:[[NSBundle mainBundle] pathForResource:@"vqu_image_music_play_animation" ofType:@"json"]]; youpaipanimationView.loopAnimation = YES; youpaipanimationView.hidden = YES; youpaipanimationView.contentMode = UIViewContentModeScaleAspectFill; [youpaipanimationView play]; [self addSubview:youpaipanimationView]; self.youpaipanimationView = youpaipanimationView; [youpaipanimationView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(16.0f); make.centerY.equalTo(self.contentView); make.size.mas_offset(CGSizeMake(12.0f, 12.0f)); }]; } - (void)youpaifmoreBtnClick{ if (self.moreBtnClickBlock != nil) { self.moreBtnClickBlock(self.youpaipmodel); } } -(void)youpaifreloadWithModel:(YOUPAILZMusicListItemModel *)model{ self.youpaipmodel = model; self.youpaipsongNameL.text = model.youpaipname; self.youpaipanimationView.hidden = !model.youpaipisPlay; // NSMutableString *artistStr = [NSMutableString string]; // for (YOUPAILZMusicArtistModel *artistModel in model.youpaipartist) { // [artistStr appendString:artistModel.youpaipname]; // if (artistModel != model.youpaipartist.lastObject) { // [artistStr appendString:@"/"]; // } // } // if (artistStr.length != 0 && model.youpaipalbumName.length != 0) { // [artistStr appendString:@" - "]; // } // [artistStr appendString:model.youpaipalbumName]; self.youpaipsingerL.text = model.youpaipsinger; } @end