增加换肤功能
This commit is contained in:
113
QXLive/HomePage(声播)/View/首页/搜索/QXSearchCell.m
Normal file
113
QXLive/HomePage(声播)/View/首页/搜索/QXSearchCell.m
Normal file
@@ -0,0 +1,113 @@
|
||||
//
|
||||
// QXSearchCell.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/5/8.
|
||||
//
|
||||
|
||||
#import "QXSearchCell.h"
|
||||
|
||||
@implementation QXSearchCell
|
||||
+ (NSString *)cellIdentifier {
|
||||
return @"QXSearchCell";
|
||||
}
|
||||
|
||||
+ (instancetype)cellWithCollectionView:(UICollectionView *)collectionView forIndexPath:(NSIndexPath *)indexPath {
|
||||
QXSearchCell *cell = (QXSearchCell*)[collectionView dequeueReusableCellWithReuseIdentifier:[QXSearchCell cellIdentifier] forIndexPath:indexPath];
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
self.contentView.backgroundColor = RGB16(0xF3F3F3);
|
||||
self.contentView.layer.cornerRadius = 11;
|
||||
self.contentView.layer.masksToBounds = YES;
|
||||
self.contentView.layer.borderColor = [UIColor blackColor].CGColor;
|
||||
self.contentView.layer.borderWidth = 0.4;
|
||||
|
||||
[self.contentView addSubview:self.backImageView];
|
||||
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.mas_equalTo(self.contentView);
|
||||
}];
|
||||
|
||||
[self.contentView addSubview:self.titleLabel];
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.center.mas_equalTo(self.contentView);
|
||||
}];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
-(void)setCellType:(QXSearchCellType)cellType{
|
||||
_cellType = cellType;
|
||||
switch (cellType) {
|
||||
case QXSearchCellTypeSearch:{
|
||||
self.contentView.backgroundColor = RGB16(0xF3F3F3);
|
||||
self.contentView.layer.cornerRadius = 11;
|
||||
self.contentView.layer.masksToBounds = YES;
|
||||
self.contentView.layer.borderColor = [UIColor blackColor].CGColor;
|
||||
self.contentView.layer.borderWidth = 0.4;
|
||||
_titleLabel.textColor = RGB16(0x666666);
|
||||
}
|
||||
break;
|
||||
case QXSearchCellTypeChangeIntroduce:{
|
||||
self.contentView.backgroundColor = RGB16(0xF3F3F3);
|
||||
self.contentView.layer.cornerRadius = 11;
|
||||
self.contentView.layer.masksToBounds = YES;
|
||||
self.contentView.layer.borderColor = [UIColor blackColor].CGColor;
|
||||
self.contentView.layer.borderWidth = 0;
|
||||
_titleLabel.textColor = RGB16(0x999999);
|
||||
}
|
||||
break;
|
||||
case QXSearchCellTypeIntroduce:{
|
||||
self.contentView.backgroundColor = RGB16(0xBBFFEB);
|
||||
self.contentView.layer.cornerRadius = 11;
|
||||
self.contentView.layer.masksToBounds = YES;
|
||||
self.contentView.layer.borderColor = [UIColor blackColor].CGColor;
|
||||
self.contentView.layer.borderWidth = 0;
|
||||
_titleLabel.textColor = RGB16(0x006B4C);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
-(void)setUserTag:(QXUserTag *)userTag{
|
||||
_userTag = userTag;
|
||||
self.titleLabel.text = userTag.tag_name;
|
||||
if (self.cellType == QXSearchCellTypeIntroduce) {
|
||||
return;
|
||||
}
|
||||
if (userTag.isSelected) {
|
||||
self.contentView.backgroundColor = RGB16(0xBBFFEB);
|
||||
self.contentView.layer.cornerRadius = 11;
|
||||
self.contentView.layer.masksToBounds = YES;
|
||||
self.contentView.layer.borderColor = [UIColor blackColor].CGColor;
|
||||
self.contentView.layer.borderWidth = 0;
|
||||
_titleLabel.textColor = RGB16(0x006B4C);
|
||||
}else{
|
||||
self.contentView.backgroundColor = RGB16(0xF3F3F3);
|
||||
self.contentView.layer.cornerRadius = 11;
|
||||
self.contentView.layer.masksToBounds = YES;
|
||||
self.contentView.layer.borderColor = [UIColor blackColor].CGColor;
|
||||
self.contentView.layer.borderWidth = 0;
|
||||
_titleLabel.textColor = RGB16(0x999999);
|
||||
}
|
||||
}
|
||||
- (UIImageView*)backImageView {
|
||||
if (!_backImageView) {
|
||||
_backImageView = [[UIImageView alloc]init];
|
||||
_backImageView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
}
|
||||
return _backImageView;
|
||||
}
|
||||
|
||||
- (UILabel*)titleLabel {
|
||||
if (!_titleLabel) {
|
||||
_titleLabel = [[UILabel alloc]init];
|
||||
_titleLabel.font = [UIFont boldSystemFontOfSize:12];
|
||||
_titleLabel.textAlignment = NSTextAlignmentCenter;
|
||||
_titleLabel.textColor = RGB16(0x666666);
|
||||
}
|
||||
return _titleLabel;
|
||||
}
|
||||
@end
|
||||
Reference in New Issue
Block a user