// // SelectContactCollectionViewCell.m // LekangGuard // // Created by ecell on 2022/10/13. // #import "SelectContactCollectionViewCell.h" @interface SelectContactCollectionViewCell () /// 头像 @property (nonatomic ,weak) UIImageView *bgImg; /// 昵称 @property (nonatomic ,weak) UILabel *titleLabel; @end @implementation SelectContactCollectionViewCell - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { //self.frame = CGRectMake(0, 0, (ScreenWidth-60)/3, Adapted(56)); // self.backgroundColor = KKBackgroundGrey; // self.layer.cornerRadius = 5; // self.layer.masksToBounds = YES; [self setCellView]; } return self; } - (void)setDeviceType:(NSInteger)deviceType { _deviceType = deviceType; } - (void)setIconImgName:(NSString *)iconImgName { _iconImgName = iconImgName; self.bgImg.image = ImageName_(iconImgName); } - (void)setNameStr:(NSString *)nameStr { _nameStr = nameStr; self.titleLabel.text = nameStr; } - (void)setCellView { UIImageView *bgImg = [UICommon ui_imageView:CGRectMake(0, 0, (SCREEN_WIDTH-75)/4, (SCREEN_WIDTH-75)/4) fileName:@""]; self.bgImg = bgImg; [self.contentView addSubview:bgImg]; UILabel *titleLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentCenter font:FontADA_(13) textColor:KKTextBlackColor text:@"" Radius:0]; self.titleLabel = titleLabel; [self.contentView addSubview:titleLabel]; [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self.contentView); make.top.equalTo(bgImg.mas_bottom).offset(8); }]; } -(void)setSelected:(BOOL)selected { [super setSelected:selected]; if (selected) { self.bgImg.image = [UICommon getClickRelationshipImageWithCodeID:self.tag deviceType:self.deviceType]; self.titleLabel.textColor = KKMainColor; } else { self.bgImg.image = [UICommon getUnclickRelationshipImageWithCodeID:self.tag deviceType:self.deviceType]; self.titleLabel.textColor = KKTextBlackColor; } } @end