修改暗黑模式功能UI

This commit is contained in:
2026-01-09 19:35:36 +08:00
parent 1b6724f043
commit 21fcbe3665
8 changed files with 1113 additions and 760 deletions

View File

@@ -6,118 +6,125 @@
//
#import "KBFunctionTagCell.h"
#import "KBFunctionView.h"
#import "Masonry.h"
@interface KBFunctionTagCell ()
@property (nonatomic, strong) UILabel *emojiLabel;
@property (nonatomic, strong) UILabel *titleLabelInternal;
@property (nonatomic, strong) UIActivityIndicatorView *loadingView;
@property(nonatomic, strong) UILabel *emojiLabel;
@property(nonatomic, strong) UILabel *titleLabelInternal;
@property(nonatomic, strong) UIActivityIndicatorView *loadingView;
@end
@implementation KBFunctionTagCell
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
self.contentView.backgroundColor = [UIColor colorWithWhite:1 alpha:0.9];
self.contentView.layer.cornerRadius = 12;
self.contentView.layer.masksToBounds = YES;
if (self = [super initWithFrame:frame]) {
self.contentView.backgroundColor = [KBFunctionView kb_cellBackgroundColor];
self.contentView.layer.cornerRadius = 12;
self.contentView.layer.masksToBounds = YES;
//
[self.contentView addSubview:self.loadingView];
[self.loadingView mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.equalTo(self.contentView);
make.width.height.mas_equalTo(16);
}];
//
[self.contentView addSubview:self.loadingView];
[self.loadingView mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.equalTo(self.contentView);
make.width.height.mas_equalTo(16);
}];
// icon + title
UIView *centerContainer = [[UIView alloc] init];
centerContainer.backgroundColor = [UIColor clearColor];
[self.contentView addSubview:centerContainer];
[centerContainer mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.contentView.mas_centerX);
make.centerY.equalTo(self.contentView.mas_centerY);
make.left.greaterThanOrEqualTo(self.contentView.mas_left).offset(6);
make.right.lessThanOrEqualTo(self.contentView).offset(-6);
}];
// icon + title
UIView *centerContainer = [[UIView alloc] init];
centerContainer.backgroundColor = [UIColor clearColor];
[self.contentView addSubview:centerContainer];
[centerContainer mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.contentView.mas_centerX);
make.centerY.equalTo(self.contentView.mas_centerY);
make.left.greaterThanOrEqualTo(self.contentView.mas_left).offset(6);
make.right.lessThanOrEqualTo(self.contentView).offset(-6);
}];
[centerContainer addSubview:self.emojiLabel];
[centerContainer addSubview:self.titleLabelInternal];
[centerContainer addSubview:self.emojiLabel];
[centerContainer addSubview:self.titleLabelInternal];
[self.emojiLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(centerContainer.mas_left);
make.centerY.equalTo(centerContainer.mas_centerY);
// emoji
make.width.height.mas_equalTo(24);
}];
[self.titleLabelInternal mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.emojiLabel.mas_right).offset(3);
make.top.equalTo(centerContainer.mas_top);
make.bottom.equalTo(centerContainer.mas_bottom);
make.right.equalTo(centerContainer.mas_right);
}];
}
return self;
[self.emojiLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(centerContainer.mas_left);
make.centerY.equalTo(centerContainer.mas_centerY);
// emoji
make.width.height.mas_equalTo(24);
}];
[self.titleLabelInternal mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.emojiLabel.mas_right).offset(3);
make.top.equalTo(centerContainer.mas_top);
make.bottom.equalTo(centerContainer.mas_bottom);
make.right.equalTo(centerContainer.mas_right);
}];
}
return self;
}
- (void)setItemModel:(KBTagItemModel *)itemModel{
_itemModel = itemModel;
self.emojiLabel.text = itemModel.emoji;
self.titleLabelInternal.text = itemModel.characterName;
- (void)setItemModel:(KBTagItemModel *)itemModel {
_itemModel = itemModel;
self.emojiLabel.text = itemModel.emoji;
self.titleLabelInternal.text = itemModel.characterName;
}
#pragma mark - Lazy
- (UILabel *)emojiLabel {
if (!_emojiLabel) {
_emojiLabel = [[UILabel alloc] init];
_emojiLabel.textAlignment = NSTextAlignmentCenter;
_emojiLabel.font = [KBFont medium:20];
_emojiLabel.adjustsFontSizeToFitWidth = YES;
}
return _emojiLabel;
if (!_emojiLabel) {
_emojiLabel = [[UILabel alloc] init];
_emojiLabel.textAlignment = NSTextAlignmentCenter;
_emojiLabel.font = [KBFont medium:20];
_emojiLabel.adjustsFontSizeToFitWidth = YES;
}
return _emojiLabel;
}
- (UILabel *)titleLabelInternal {
if (!_titleLabelInternal) {
_titleLabelInternal = [[UILabel alloc] init];
_titleLabelInternal.font = [KBFont medium:10];
_titleLabelInternal.textColor = [UIColor colorWithHex:0x1B1F1A];
//
_titleLabelInternal.numberOfLines = 2;
_titleLabelInternal.lineBreakMode = NSLineBreakByTruncatingTail;
}
return _titleLabelInternal;
if (!_titleLabelInternal) {
_titleLabelInternal = [[UILabel alloc] init];
_titleLabelInternal.font = [KBFont medium:10];
_titleLabelInternal.textColor = [KBFunctionView kb_cellTextColor];
//
_titleLabelInternal.numberOfLines = 2;
_titleLabelInternal.lineBreakMode = NSLineBreakByTruncatingTail;
}
return _titleLabelInternal;
}
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
static UIActivityIndicatorViewStyle KBSpinnerStyle(void) { return UIActivityIndicatorViewStyleMedium; }
static UIActivityIndicatorViewStyle KBSpinnerStyle(void) {
return UIActivityIndicatorViewStyleMedium;
}
#else
static UIActivityIndicatorViewStyle KBSpinnerStyle(void) { return UIActivityIndicatorViewStyleGray; }
static UIActivityIndicatorViewStyle KBSpinnerStyle(void) {
return UIActivityIndicatorViewStyleGray;
}
#endif
- (UIActivityIndicatorView *)loadingView {
if (!_loadingView) {
_loadingView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:KBSpinnerStyle()];
_loadingView.hidesWhenStopped = YES;
_loadingView.color = [UIColor grayColor];
_loadingView.hidden = YES;
}
return _loadingView;
if (!_loadingView) {
_loadingView = [[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:KBSpinnerStyle()];
_loadingView.hidesWhenStopped = YES;
_loadingView.color = [UIColor grayColor];
_loadingView.hidden = YES;
}
return _loadingView;
}
#pragma mark - Expose
- (UILabel *)titleLabel { return self.titleLabelInternal; }
- (UILabel *)titleLabel {
return self.titleLabelInternal;
}
- (void)setLoading:(BOOL)loading {
if (loading) {
self.loadingView.hidden = NO;
[self.loadingView startAnimating];
} else {
[self.loadingView stopAnimating];
self.loadingView.hidden = YES;
}
if (loading) {
self.loadingView.hidden = NO;
[self.loadingView startAnimating];
} else {
[self.loadingView stopAnimating];
self.loadingView.hidden = YES;
}
}
@end