//
|
// PBUserCollectionViewCell.m
|
// IphoneBIMe
|
//
|
// Created by zjf on 2021/1/8.
|
// Copyright © 2021 ProBIM. All rights reserved.
|
//
|
|
#import "PBUserCollectionViewCell.h"
|
#import "PBUserModel.h"
|
@interface PBUserCollectionViewCell()
|
@property (nonatomic, weak) UILabel *nameL;
|
@end
|
@implementation PBUserCollectionViewCell
|
- (instancetype)initWithFrame:(CGRect)frame {
|
if (self = [super initWithFrame:frame]) {
|
[self setupUI];
|
}
|
return self;
|
}
|
- (void)setupUI {
|
UIView *bgV = [[UIView alloc] init];
|
bgV.backgroundColor = PBColor(40, 58, 79);
|
[self.contentView addSubview:bgV];
|
[bgV mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.bottom.left.right.equalTo(self.contentView);
|
}];
|
[bgV circleViewWithRadius:6];
|
UILabel *nameL = [UILabel z_labelWithText:@"" Color:[UIColor whiteColor] isBold:YES Font:14];
|
nameL.textAlignment = NSTextAlignmentCenter;
|
[self.contentView addSubview:nameL];
|
[nameL mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.bottom.left.right.equalTo(bgV);
|
}];
|
self.nameL = nameL;
|
}
|
- (void)setUserModel:(PBUserModel *)userModel {
|
_userModel = userModel;
|
BOOL isChiness = [self IsChinese:userModel.RealName];
|
if (isChiness) {
|
self.nameL.text = [userModel.RealName substringFromIndex:userModel.RealName.length - 1];
|
}else {
|
self.nameL.text = [userModel.RealName substringToIndex:1];
|
}
|
}
|
- (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;
|
}
|
|
@end
|