// // YOUPAILZLiveFollowCell.m // TIANYAN // // Created by CY on 2021/5/26. // Copyright © 2021 leo. All rights reserved. // #import "YOUPAILZLiveFollowCell.h" @interface YOUPAILZLiveFollowCell () @property (nonatomic, strong) YOUPAILZLiveModel *youpaipmodel; @property (nonatomic, strong) NSIndexPath *youpaipindexPath; @property (nonatomic, weak) UIImageView *youpaipavatarImgV; @end @implementation YOUPAILZLiveFollowCell - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { self.transform = CGAffineTransformMakeRotation(M_PI); self.selectionStyle = UITableViewCellSelectionStyleNone; self.backgroundColor = [UIColor clearColor]; [self youpaifinitUI]; } return self; } - (void)youpaifinitUI{ UIView *bgV = [[UIView alloc] init]; bgV.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3f]; bgV.layer.cornerRadius = 17.5f; bgV.clipsToBounds = YES; [self.contentView addSubview:bgV]; [bgV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(5.0f); make.top.offset(6.0f); make.bottom.offset(0.0f); }]; UIImageView *youpaipavatarImgV = [[UIImageView alloc] init]; youpaipavatarImgV.contentMode = UIViewContentModeScaleAspectFill; youpaipavatarImgV.layer.cornerRadius = 16.5f; youpaipavatarImgV.clipsToBounds = YES; [bgV addSubview:youpaipavatarImgV]; self.youpaipavatarImgV = youpaipavatarImgV; [youpaipavatarImgV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.top.offset(1.0f); make.bottom.offset(-1.0f); make.size.mas_offset(CGSizeMake(33.0f, 33.0f)); }]; UIButton *youpaipfollowBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [youpaipfollowBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(34.0f, 23.0f) FromColors:@[HexColorFromRGB(0xE85DF7),HexColorFromRGB(0xFF3DA5)] ByGradientType:GradientLeftToRight] forState:UIControlStateNormal]; youpaipfollowBtn.layer.cornerRadius = 11.5f; youpaipfollowBtn.clipsToBounds = YES; youpaipfollowBtn.titleLabel.font = LCFont(12.0f); [youpaipfollowBtn setTitle:@"关注" forState:UIControlStateNormal]; [youpaipfollowBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; [youpaipfollowBtn addTarget:self action:@selector(youpaiffollowBtnClick) forControlEvents:UIControlEventTouchUpInside]; [bgV addSubview:youpaipfollowBtn]; [youpaipfollowBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.right.offset(-4.0f); make.size.mas_offset(CGSizeMake(34.0f, 23.0f)); make.centerY.equalTo(bgV.mas_centerY); }]; UILabel *contentL = [[UILabel alloc] init]; contentL.font = LCBoldFont(14.0f); contentL.textColor = [UIColor whiteColor]; contentL.text = @"点关注 不迷路"; [bgV addSubview:contentL]; [contentL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(youpaipavatarImgV.mas_right).offset(4.0f); make.right.equalTo(youpaipfollowBtn.mas_left).offset(-4.0f); make.top.bottom.offset(0.0f); }]; } - (void)youpaiffollowBtnClick{ if (self.youpaipfollowBlock != nil) { self.youpaipfollowBlock(self.youpaipmodel, self.youpaipindexPath); } } - (void)youpaifreloadWithModel:(YOUPAILZLiveModel *)model indexPath:(NSIndexPath *)indexPath{ self.youpaipmodel = model; self.youpaipindexPath = indexPath; [self.youpaipavatarImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:model.youpaipuser_info.youpaipavatar]]; } @end