This commit is contained in:
2025-11-12 16:49:19 +08:00
parent fea22aecab
commit 2f4205ad1a
7 changed files with 144 additions and 18 deletions

View File

@@ -11,6 +11,7 @@
@interface KBFunctionTagCell ()
@property (nonatomic, strong) UILabel *titleLabelInternal;
@property (nonatomic, strong) UIImageView *iconViewInternal;
@property (nonatomic, strong) UIActivityIndicatorView *loadingView;
@end
@implementation KBFunctionTagCell
@@ -34,6 +35,14 @@
make.right.equalTo(self.contentView.mas_right).offset(-10);
make.centerY.equalTo(self.contentView.mas_centerY);
}];
//
[self.contentView addSubview:self.loadingView];
[self.loadingView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(self.contentView);
make.right.equalTo(self.contentView.mas_right).offset(-10);
make.width.height.mas_equalTo(16);
}];
}
return self;
}
@@ -64,10 +73,35 @@
return _titleLabelInternal;
}
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
static UIActivityIndicatorViewStyle KBSpinnerStyle(void) { return UIActivityIndicatorViewStyleMedium; }
#else
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;
}
#pragma mark - Expose
- (UILabel *)titleLabel { return self.titleLabelInternal; }
- (UIImageView *)iconView { return self.iconViewInternal; }
@end
- (void)setLoading:(BOOL)loading {
if (loading) {
self.loadingView.hidden = NO;
[self.loadingView startAnimating];
} else {
[self.loadingView stopAnimating];
self.loadingView.hidden = YES;
}
}
@end