This commit is contained in:
2025-12-03 19:38:55 +08:00
parent 716f91bdd0
commit 43e8b85656
7 changed files with 49 additions and 56 deletions

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "切图 223@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "切图 223@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@@ -79,19 +79,7 @@
self.titleLabel.text = character.characterName ?: @"";
self.subLabel.text = character.download ?: @"";
// +
UIImage *placeholder = nil;
if (!placeholder) {
// 使
CGFloat side = 56.0;
UIGraphicsBeginImageContextWithOptions(CGSizeMake(side, side), NO, 0);
CGContextRef ctx = UIGraphicsGetCurrentContext();
[[UIColor colorWithWhite:0.9 alpha:1.0] setFill];
CGContextFillEllipseInRect(ctx, CGRectMake(0, 0, side, side));
placeholder = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
[self.avatarView kb_setAvatarURL:character.avatarUrl placeholder:placeholder];
[self.avatarView kb_setAvatarURL:character.avatarUrl placeholder:KBPlaceholderImage];
//
BOOL joined = character.added;

View File

@@ -13,18 +13,12 @@ NS_ASSUME_NONNULL_BEGIN
/// 首页排行榜卡片 Cell两列
@interface HomeRankCardCell : UICollectionViewCell
/// 当前展示的角色模型
/// 当前展示的角色模型设置后cell 会在 setter 中根据模型刷新 UI
@property (nonatomic, strong, nullable) KBCharacter *character;
/// 点击加号/勾选按钮回调
@property (nonatomic, copy, nullable) void (^onTapAction)(void);
/// 旧的配置方法(兼容用,不推荐继续使用)
- (void)configureWithTitle:(NSString *)title
desc:(NSString *)desc
people:(NSString *)people
added:(BOOL)added;
@end
NS_ASSUME_NONNULL_END

View File

@@ -8,11 +8,12 @@
@import UIKit;
#import "HomeRankCardCell.h"
#import "UIView+KBShadow.h"
#import "UIImageView+KBWebImage.h"
@interface HomeRankCardCell ()
@property (nonatomic, strong) UIView *shadowView; //
@property (nonatomic, strong) UIImageView *cardView; //
@property (nonatomic, strong) UIView *badgeCircle; //
@property (nonatomic, strong) UIView *cardView; //
@property (nonatomic, strong) UIImageView *averImageView; //
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *descLabel;
@property (nonatomic, strong) UILabel *peopleLabel;
@@ -35,7 +36,7 @@
// 使访
[self.contentView addSubview:self.shadowView];
[self.shadowView addSubview:self.cardView];
[self.contentView addSubview:self.badgeCircle];
[self.contentView addSubview:self.averImageView];
[self.cardView addSubview:self.titleLabel];
[self.cardView addSubview:self.descLabel];
[self.cardView addSubview:self.peopleLabel];
@@ -56,14 +57,14 @@
make.edges.equalTo(self.shadowView).insets(UIEdgeInsetsMake(0, 8, 0, 8));
}];
[self.badgeCircle mas_makeConstraints:^(MASConstraintMaker *make) {
[self.averImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.cardView);
make.centerY.equalTo(self.shadowView.mas_top);
make.width.height.mas_equalTo(68);
}];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.badgeCircle.mas_bottom).offset(13);
make.top.equalTo(self.averImageView.mas_bottom).offset(13);
make.left.equalTo(self.cardView.mas_left).offset(18);
make.right.equalTo(self.cardView.mas_right).offset(-18);
make.height.mas_equalTo(23);
@@ -94,7 +95,7 @@
//
[self.shadowView kb_updateShadowPath];
_badgeCircle.layer.cornerRadius = 34;
self.averImageView.layer.cornerRadius = 34;
}
- (void)prepareForReuse {
@@ -106,12 +107,14 @@
if (self.onTapAction) self.onTapAction();
}
- (void)configureWithTitle:(NSString *)title desc:(NSString *)desc people:(NSString *)people added:(BOOL)added {
- (void)setCharacter:(KBCharacter *)character {
_character = character;
BOOL added = character.added;
self.added = added;
self.titleLabel.text = title ?: @"";
self.descLabel.text = desc ?: @"";
self.peopleLabel.text = people ?: @"";
self.titleLabel.text = character.characterName;
self.descLabel.text = character.characterBackground;
self.peopleLabel.text = character.download;
[self.averImageView kb_setAvatarURL:character.avatarUrl placeholder:KBPlaceholderImage];
if (added) {
//
self.actionBtn.backgroundColor = [UIColor colorWithWhite:0.93 alpha:1.0];
@@ -125,17 +128,6 @@
}
}
- (void)setCharacter:(KBCharacter *)character {
_character = character;
NSString *title = character.characterName ?: @"";
NSString *people = character.download ?: @"";
NSString *desc = @"Be Neither Too Close\nNor Too Distant..."; //
BOOL added = character.added;
[self configureWithTitle:title desc:desc people:people added:added];
}
#pragma mark - Lazy UI
- (UIView *)shadowView {
@@ -146,27 +138,22 @@
return _shadowView;
}
- (UIImageView *)cardView {
- (UIView *)cardView {
if (!_cardView) {
_cardView = [[UIImageView alloc] init];
_cardView = [[UIView alloc] init];
_cardView.backgroundColor = UIColor.whiteColor;
_cardView.layer.cornerRadius = 18.0;
_cardView.layer.masksToBounds = YES;
_cardView.contentMode = UIViewContentModeScaleAspectFill;
//
_cardView.image = [UIImage imageNamed:@"home_rank_card_bg"];
}
return _cardView;
}
- (UIView *)badgeCircle {
if (!_badgeCircle) {
_badgeCircle = [UIView new];
_badgeCircle.backgroundColor = UIColor.whiteColor;
_badgeCircle.layer.borderColor = [UIColor colorWithRed:0.78 green:0.90 blue:0.20 alpha:1.0].CGColor;
_badgeCircle.layer.borderWidth = 3.0;
- (UIImageView *)averImageView {
if (!_averImageView) {
_averImageView = [UIImageView new];
_averImageView.backgroundColor = UIColor.whiteColor;
_averImageView.layer.borderColor = [UIColor colorWithRed:0.78 green:0.90 blue:0.20 alpha:1.0].CGColor;
_averImageView.layer.borderWidth = 3.0;
}
return _badgeCircle;
return _averImageView;
}
- (UILabel *)titleLabel {

View File

@@ -67,6 +67,8 @@
/// 第一次安装
#define KBSexSelectShownKey @"kKBSexSelectShownKey"
#define KBPlaceholderImage [UIImage imageNamed:@"placeholder_icon"]
/// UI 尺寸/设备宏
// 屏幕尺寸
#define KB_SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)