1
This commit is contained in:
22
keyBoard/Assets.xcassets/Ohter/placeholder_icon.imageset/Contents.json
vendored
Normal file
22
keyBoard/Assets.xcassets/Ohter/placeholder_icon.imageset/Contents.json
vendored
Normal 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
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
keyBoard/Assets.xcassets/Ohter/placeholder_icon.imageset/切图 223@2x.png
vendored
Normal file
BIN
keyBoard/Assets.xcassets/Ohter/placeholder_icon.imageset/切图 223@2x.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
BIN
keyBoard/Assets.xcassets/Ohter/placeholder_icon.imageset/切图 223@3x.png
vendored
Normal file
BIN
keyBoard/Assets.xcassets/Ohter/placeholder_icon.imageset/切图 223@3x.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
@@ -79,19 +79,7 @@
|
|||||||
self.titleLabel.text = character.characterName ?: @"";
|
self.titleLabel.text = character.characterName ?: @"";
|
||||||
self.subLabel.text = character.download ?: @"";
|
self.subLabel.text = character.download ?: @"";
|
||||||
|
|
||||||
// 头像:圆形占位 + 网络图
|
[self.avatarView kb_setAvatarURL:character.avatarUrl placeholder:KBPlaceholderImage];
|
||||||
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];
|
|
||||||
|
|
||||||
// 加入状态
|
// 加入状态
|
||||||
BOOL joined = character.added;
|
BOOL joined = character.added;
|
||||||
|
|||||||
@@ -13,18 +13,12 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
/// 首页排行榜卡片 Cell(两列)
|
/// 首页排行榜卡片 Cell(两列)
|
||||||
@interface HomeRankCardCell : UICollectionViewCell
|
@interface HomeRankCardCell : UICollectionViewCell
|
||||||
|
|
||||||
/// 当前展示的角色模型
|
/// 当前展示的角色模型(设置后,cell 会在 setter 中根据模型刷新 UI)
|
||||||
@property (nonatomic, strong, nullable) KBCharacter *character;
|
@property (nonatomic, strong, nullable) KBCharacter *character;
|
||||||
|
|
||||||
/// 点击加号/勾选按钮回调
|
/// 点击加号/勾选按钮回调
|
||||||
@property (nonatomic, copy, nullable) void (^onTapAction)(void);
|
@property (nonatomic, copy, nullable) void (^onTapAction)(void);
|
||||||
|
|
||||||
/// 旧的配置方法(兼容用,不推荐继续使用)
|
|
||||||
- (void)configureWithTitle:(NSString *)title
|
|
||||||
desc:(NSString *)desc
|
|
||||||
people:(NSString *)people
|
|
||||||
added:(BOOL)added;
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
NS_ASSUME_NONNULL_END
|
||||||
|
|||||||
@@ -8,11 +8,12 @@
|
|||||||
@import UIKit;
|
@import UIKit;
|
||||||
#import "HomeRankCardCell.h"
|
#import "HomeRankCardCell.h"
|
||||||
#import "UIView+KBShadow.h"
|
#import "UIView+KBShadow.h"
|
||||||
|
#import "UIImageView+KBWebImage.h"
|
||||||
|
|
||||||
@interface HomeRankCardCell ()
|
@interface HomeRankCardCell ()
|
||||||
@property (nonatomic, strong) UIView *shadowView; // 阴影容器(不裁剪)
|
@property (nonatomic, strong) UIView *shadowView; // 阴影容器(不裁剪)
|
||||||
@property (nonatomic, strong) UIImageView *cardView; // 卡片背景图片
|
@property (nonatomic, strong) UIView *cardView; // 卡片背景图片
|
||||||
@property (nonatomic, strong) UIView *badgeCircle; // 顶部圆形描边
|
@property (nonatomic, strong) UIImageView *averImageView; // 顶部圆形描边
|
||||||
@property (nonatomic, strong) UILabel *titleLabel;
|
@property (nonatomic, strong) UILabel *titleLabel;
|
||||||
@property (nonatomic, strong) UILabel *descLabel;
|
@property (nonatomic, strong) UILabel *descLabel;
|
||||||
@property (nonatomic, strong) UILabel *peopleLabel;
|
@property (nonatomic, strong) UILabel *peopleLabel;
|
||||||
@@ -35,7 +36,7 @@
|
|||||||
// 使用懒加载属性,保证首次访问时创建
|
// 使用懒加载属性,保证首次访问时创建
|
||||||
[self.contentView addSubview:self.shadowView];
|
[self.contentView addSubview:self.shadowView];
|
||||||
[self.shadowView addSubview:self.cardView];
|
[self.shadowView addSubview:self.cardView];
|
||||||
[self.contentView addSubview:self.badgeCircle];
|
[self.contentView addSubview:self.averImageView];
|
||||||
[self.cardView addSubview:self.titleLabel];
|
[self.cardView addSubview:self.titleLabel];
|
||||||
[self.cardView addSubview:self.descLabel];
|
[self.cardView addSubview:self.descLabel];
|
||||||
[self.cardView addSubview:self.peopleLabel];
|
[self.cardView addSubview:self.peopleLabel];
|
||||||
@@ -56,14 +57,14 @@
|
|||||||
make.edges.equalTo(self.shadowView).insets(UIEdgeInsetsMake(0, 8, 0, 8));
|
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.centerX.equalTo(self.cardView);
|
||||||
make.centerY.equalTo(self.shadowView.mas_top);
|
make.centerY.equalTo(self.shadowView.mas_top);
|
||||||
make.width.height.mas_equalTo(68);
|
make.width.height.mas_equalTo(68);
|
||||||
}];
|
}];
|
||||||
|
|
||||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
[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.left.equalTo(self.cardView.mas_left).offset(18);
|
||||||
make.right.equalTo(self.cardView.mas_right).offset(-18);
|
make.right.equalTo(self.cardView.mas_right).offset(-18);
|
||||||
make.height.mas_equalTo(23);
|
make.height.mas_equalTo(23);
|
||||||
@@ -94,7 +95,7 @@
|
|||||||
// 阴影路径需在尺寸确定后更新(封装方法会基于记录参数自动计算)
|
// 阴影路径需在尺寸确定后更新(封装方法会基于记录参数自动计算)
|
||||||
[self.shadowView kb_updateShadowPath];
|
[self.shadowView kb_updateShadowPath];
|
||||||
|
|
||||||
_badgeCircle.layer.cornerRadius = 34;
|
self.averImageView.layer.cornerRadius = 34;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)prepareForReuse {
|
- (void)prepareForReuse {
|
||||||
@@ -106,12 +107,14 @@
|
|||||||
if (self.onTapAction) self.onTapAction();
|
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.added = added;
|
||||||
self.titleLabel.text = title ?: @"";
|
self.titleLabel.text = character.characterName;
|
||||||
self.descLabel.text = desc ?: @"";
|
self.descLabel.text = character.characterBackground;
|
||||||
self.peopleLabel.text = people ?: @"";
|
self.peopleLabel.text = character.download;
|
||||||
|
[self.averImageView kb_setAvatarURL:character.avatarUrl placeholder:KBPlaceholderImage];
|
||||||
if (added) {
|
if (added) {
|
||||||
// 已添加:灰底、对勾
|
// 已添加:灰底、对勾
|
||||||
self.actionBtn.backgroundColor = [UIColor colorWithWhite:0.93 alpha:1.0];
|
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
|
#pragma mark - Lazy UI
|
||||||
|
|
||||||
- (UIView *)shadowView {
|
- (UIView *)shadowView {
|
||||||
@@ -146,27 +138,22 @@
|
|||||||
return _shadowView;
|
return _shadowView;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (UIImageView *)cardView {
|
- (UIView *)cardView {
|
||||||
if (!_cardView) {
|
if (!_cardView) {
|
||||||
_cardView = [[UIImageView alloc] init];
|
_cardView = [[UIView alloc] init];
|
||||||
_cardView.backgroundColor = UIColor.whiteColor;
|
_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;
|
return _cardView;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (UIView *)badgeCircle {
|
- (UIImageView *)averImageView {
|
||||||
if (!_badgeCircle) {
|
if (!_averImageView) {
|
||||||
_badgeCircle = [UIView new];
|
_averImageView = [UIImageView new];
|
||||||
_badgeCircle.backgroundColor = UIColor.whiteColor;
|
_averImageView.backgroundColor = UIColor.whiteColor;
|
||||||
_badgeCircle.layer.borderColor = [UIColor colorWithRed:0.78 green:0.90 blue:0.20 alpha:1.0].CGColor;
|
_averImageView.layer.borderColor = [UIColor colorWithRed:0.78 green:0.90 blue:0.20 alpha:1.0].CGColor;
|
||||||
_badgeCircle.layer.borderWidth = 3.0;
|
_averImageView.layer.borderWidth = 3.0;
|
||||||
}
|
}
|
||||||
return _badgeCircle;
|
return _averImageView;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (UILabel *)titleLabel {
|
- (UILabel *)titleLabel {
|
||||||
|
|||||||
@@ -67,6 +67,8 @@
|
|||||||
/// 第一次安装
|
/// 第一次安装
|
||||||
#define KBSexSelectShownKey @"kKBSexSelectShownKey"
|
#define KBSexSelectShownKey @"kKBSexSelectShownKey"
|
||||||
|
|
||||||
|
#define KBPlaceholderImage [UIImage imageNamed:@"placeholder_icon"]
|
||||||
|
|
||||||
/// UI 尺寸/设备宏
|
/// UI 尺寸/设备宏
|
||||||
// 屏幕尺寸
|
// 屏幕尺寸
|
||||||
#define KB_SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
|
#define KB_SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
|
||||||
|
|||||||
Reference in New Issue
Block a user