// // PBMultiSelectPersonCell.m // IphoneBIMe // // Created by zjf on 2021/1/7. // Copyright © 2021 ProBIM. All rights reserved. // #import "PBMultiSelectPersonCell.h" #import "PBUserModel.h" @interface PBMultiSelectPersonCell() @property (nonatomic, weak) UILabel *nameShorthandL; @property (nonatomic, weak) UILabel *nameL; @property (nonatomic, weak) UILabel *typeL; @property (nonatomic, weak) UIImageView *chooseV; @end @implementation PBMultiSelectPersonCell - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { [self setupUI]; } return self; } - (void)setupUI { UIImageView *chooseV = [[UIImageView alloc] init]; [self.contentView addSubview:chooseV]; [chooseV mas_makeConstraints:^(MASConstraintMaker *make) { make.size.mas_equalTo(CGSizeMake(24, 24)); make.left.equalTo(self.contentView).offset(12); make.centerY.equalTo(self.contentView); }]; UIView *nameBgV = [[UIView alloc] init]; nameBgV.backgroundColor = PBColor(40, 58, 79); [self.contentView addSubview:nameBgV]; [nameBgV mas_makeConstraints:^(MASConstraintMaker *make) { make.size.mas_equalTo(CGSizeMake(40, 40)); make.left.equalTo(chooseV.mas_right).offset(10); make.centerY.equalTo(self.contentView); }]; [nameBgV circleViewWithRadius:6]; UILabel *nameShorthandL = [UILabel z_labelWithText:@"" Color:[UIColor whiteColor] isBold:YES Font:14]; nameShorthandL.textAlignment = NSTextAlignmentCenter; [self.contentView addSubview:nameShorthandL]; [nameShorthandL mas_makeConstraints:^(MASConstraintMaker *make) { make.top.bottom.left.right.equalTo(nameBgV); }]; UILabel *nameL = [UILabel z_labelWithText:@"" Color:PBColor(40, 58, 79) isBold:YES Font:14]; [self.contentView addSubview:nameL]; [nameL mas_makeConstraints:^(MASConstraintMaker *make) { make.height.equalTo(@20); make.left.equalTo(nameBgV.mas_right).offset(10); make.centerY.equalTo(self.contentView); make.right.equalTo(self.contentView).offset(-160); }]; UILabel *typeL = [UILabel z_labelWithText:@"" Color:PBColor(97, 111, 125) isBold:NO Font:13]; typeL.textAlignment = NSTextAlignmentRight; [self.contentView addSubview:typeL]; [typeL mas_makeConstraints:^(MASConstraintMaker *make) { make.height.equalTo(@16); make.left.equalTo(nameL.mas_right).offset(30); make.right.equalTo(self.contentView).offset(-35); make.centerY.equalTo(self.contentView); }]; self.nameShorthandL = nameShorthandL; self.nameL = nameL; self.typeL = typeL; self.chooseV = chooseV; } - (void)setUserModel:(PBUserModel *)userModel { _userModel = userModel; if (userModel.isSelect) { self.chooseV.image = [UIImage imageNamed:@"select_circle_select"]; }else { self.chooseV.image = [UIImage imageNamed:@"select_circle"]; } BOOL isChiness = [self IsChinese:userModel.RealName]; if (isChiness) { self.nameShorthandL.text = [userModel.RealName substringFromIndex:userModel.RealName.length - 1]; }else { self.nameShorthandL.text = [userModel.RealName substringToIndex:1]; } self.nameL.text = userModel.RealName; NSArray *role = userModel.RoleNames; if (role.count > 0) { self.typeL.text = role[0]; } } - (BOOL)IsChinese:(NSString *)str { for(int i=0; i< [str length];i++){ int a = [str characterAtIndex:i]; if( a > 0x4e00 && a < 0x9fff){ return YES; } } return NO; } - (void)awakeFromNib { [super awakeFromNib]; // Initialization code } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } @end