// // YOUPAIMyNetworkCell.m // MSYOUPAI // // Created by xiaohaoran on 2022/3/11. // Copyright © 2022 MS. All rights reserved. // #import "YOUPAIMyNetworkCell.h" #import "YOUPAISexView.h" @interface YOUPAIMyNetworkCell () @property(nonatomic,strong)UIImageView *youpaipavatarImgV; @property(nonatomic,strong)UILabel *youpaipnicknameL; @property(nonatomic,strong)YOUPAISexView *youpaipsexView; @property(nonatomic,strong)UILabel *youpaiContent; @property(nonatomic,strong)UIImageView *personImageView; @property(nonatomic,strong)UILabel *youpaiTimeLabel; @property(nonatomic,strong)UILabel *youpaiPriceLabel; @end @implementation YOUPAIMyNetworkCell -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { [self setSubView]; } return self; } -(void)setSubView{ //bg UIView *youpaiBgView = [UIView new]; [self.contentView addSubview:youpaiBgView]; [youpaiBgView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(0); make.left.mas_equalTo(12); make.right.mas_equalTo(-12); make.bottom.mas_equalTo(-8); }]; youpaiBgView.backgroundColor = LCWhiteColor; youpaiBgView.layer.cornerRadius = 10; youpaiBgView.clipsToBounds = YES; //头像 UIImageView *youpaipavatarImgV = [[UIImageView alloc]init]; [youpaiBgView addSubview:youpaipavatarImgV]; self.youpaipavatarImgV = youpaipavatarImgV; [youpaipavatarImgV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(12.0f); make.top.mas_equalTo(15); make.size.mas_equalTo(CGSizeMake(40, 40));; }]; youpaipavatarImgV.layer.cornerRadius = 20; youpaipavatarImgV.layer.masksToBounds = YES; //昵称 UILabel *youpaipnicknameL = [[UILabel alloc] init]; youpaipnicknameL.font = LCBoldFont(14); youpaipnicknameL.textColor = [UIColor whiteColor]; [youpaiBgView addSubview:youpaipnicknameL]; self.youpaipnicknameL = youpaipnicknameL; [youpaipnicknameL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(youpaipavatarImgV.mas_right).offset(8.0f); make.top.mas_equalTo(youpaipavatarImgV).offset(2.5); }]; youpaipnicknameL.textColor = LZ273145Color; youpaipnicknameL.font = LCBoldFont(14); // CGFloat width = 0; // if (youpaipmodel.nickname.length>5) { // NSString *str = [youpaipmodel.nickname substringToIndex:5]; // width = [LCTools widthWithString:str withFont:LCBoldFont(14)]+5; // }else{ // width = [LCTools widthWithString:youpaipmodel.nickname withFont:LCBoldFont(14)]+5; // } YOUPAISexView *sexView = [[YOUPAISexView alloc] init]; [youpaiBgView addSubview:sexView]; self.youpaipsexView = sexView; [sexView makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(youpaipnicknameL.right).offset(@2); make.centerY.equalTo(youpaipnicknameL); make.size.mas_equalTo(CGSizeMake(30, 15)); }]; [sexView youpaifreloadWithSex:1 age:18]; //真人图标 UIImageView *personImageView = [UIImageView new]; self.personImageView = personImageView; [youpaiBgView addSubview:personImageView]; [personImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(sexView.right).offset(@2); make.centerY.equalTo(sexView); make.size.mas_equalTo(CGSizeMake(37, 16)); }]; personImageView.image = [UIImage imageNamed:@"vqu_images_zhenrentag"]; // //内容 UILabel *youpaiContent = [UILabel new]; self.youpaiContent = youpaiContent; [youpaiBgView addSubview:youpaiContent]; [youpaiContent mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(youpaipnicknameL); make.top.mas_equalTo(youpaipnicknameL.mas_bottom).offset(4); }]; self.youpaiContent.textColor = LZA3AABEColor; self.youpaiContent.font = [UIFont systemFontOfSize:12]; //拷贝按钮 UIButton *youpaicopyBtn = [UIButton new]; [youpaiBgView addSubview:youpaicopyBtn]; [youpaicopyBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(youpaiContent.mas_right).offset(2); make.centerY.mas_equalTo(youpaiContent); make.size.mas_equalTo(CGSizeMake(12, 12)); }]; [youpaicopyBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_ZY_copy"] forState:UIControlStateNormal]; [youpaicopyBtn addTarget:self action:@selector(youpaicopyBtnClick) forControlEvents:UIControlEventTouchUpInside]; //注册时间 UILabel *youpaiTimeLabel = [UILabel new]; self.youpaiTimeLabel= youpaiTimeLabel; [youpaiBgView addSubview:youpaiTimeLabel]; [youpaiTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(youpaipnicknameL); make.top.mas_equalTo(youpaiContent.mas_bottom).offset(6); }]; youpaiTimeLabel.textColor = LZA3AABEColor; youpaiTimeLabel.font = [UIFont systemFontOfSize:12]; // youpaiTimeLabel.text = @"2021-11-22"; //价格 UILabel *youpaiPriceLabel = [UILabel new]; self.youpaiPriceLabel = youpaiPriceLabel; [youpaiBgView addSubview:youpaiPriceLabel]; [youpaiPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.mas_equalTo(personImageView); make.right.mas_equalTo(-12); }]; youpaiPriceLabel.textColor = LZ7C69FEColor; youpaiPriceLabel.font = LZDinFont(15); //贡献label UILabel *youpaiPriceTitleLabel = [UILabel new]; [youpaiBgView addSubview:youpaiPriceTitleLabel]; [youpaiPriceTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(youpaiPriceLabel.mas_bottom).offset(8.5); make.right.mas_equalTo(youpaiPriceLabel); }]; youpaiPriceTitleLabel.text = @"贡献(元)"; youpaiPriceTitleLabel.textColor = LZ273145Color; youpaiPriceTitleLabel.font = [UIFont systemFontOfSize:12]; } -(void)youpaicopyBtnClick{ NSString *inviteCode = [NSString stringWithFormat:@"%@",self.model.youpaiusercode]; UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; pasteboard.string = inviteCode; [ZCHUDHelper showTitle:@"复制成功,快去粘贴吧!"]; } -(void)setModel:(YOUPAIMyNetworkModel *)model{ _model = model; self.personImageView.hidden = YES; self.youpaipnicknameL.text = model.youpainickname; [self.youpaipsexView youpaifreloadWithSex:model.youpaigender age:model.youpaiage]; if (model.youpaiis_anchor == 1) { self.personImageView.hidden = NO; } self.youpaiContent.text = [NSString stringWithFormat:@"ID:%@",model.youpaiusercode]; self.youpaiTimeLabel.text = [NSString stringWithFormat:@"注册时间:%@",model.youpaicreatetime]; self.youpaiPriceLabel.text = model.youpaicontribution; [self.youpaipavatarImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:model.youpaiavatar] placeholderImage:nil]; } @end