Files
midi_ios/QXLive/HomePage(声播)/View/首页/搜索/QXSearchCell.m
2025-08-15 18:39:24 +08:00

114 lines
4.1 KiB
Objective-C

//
// 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 = QXConfig.themeColor;
}
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 = RGB16A(0x6C49E4, 0.1);
self.contentView.layer.cornerRadius = 11;
self.contentView.layer.masksToBounds = YES;
self.contentView.layer.borderColor = [UIColor blackColor].CGColor;
self.contentView.layer.borderWidth = 0;
_titleLabel.textColor = QXConfig.themeColor;
}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