3
This commit is contained in:
@@ -14,6 +14,8 @@
|
||||
0477BD952EBAFF4E0055D639 /* KBURLOpenBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 0477BD932EBAFF4E0055D639 /* KBURLOpenBridge.m */; };
|
||||
0477BDF02EBB76E30055D639 /* HomeSheetVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 0477BDEF2EBB76E30055D639 /* HomeSheetVC.m */; };
|
||||
0477BDF32EBB7B850055D639 /* KBDirectionIndicatorView.m in Sources */ = {isa = PBXBuildFile; fileRef = 0477BDF22EBB7B850055D639 /* KBDirectionIndicatorView.m */; };
|
||||
A1B2E1012EBC7AAA00000001 /* KBTopThreeView.m in Sources */ = {isa = PBXBuildFile; fileRef = A1B2E0022EBC7AAA00000001 /* KBTopThreeView.m */; };
|
||||
A1B2E1022EBC7AAA00000001 /* HomeHotCell.m in Sources */ = {isa = PBXBuildFile; fileRef = A1B2E0042EBC7AAA00000001 /* HomeHotCell.m */; };
|
||||
0477BDF72EBC63A80055D639 /* KBTestVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 0477BDF62EBC63A80055D639 /* KBTestVC.m */; };
|
||||
0477BDFA2EBC66340055D639 /* HomeHeadView.m in Sources */ = {isa = PBXBuildFile; fileRef = 0477BDF92EBC66340055D639 /* HomeHeadView.m */; };
|
||||
0477BDFD2EBC6A170055D639 /* HomeHotVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 0477BDFC2EBC6A170055D639 /* HomeHotVC.m */; };
|
||||
@@ -107,6 +109,10 @@
|
||||
0477BDEF2EBB76E30055D639 /* HomeSheetVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HomeSheetVC.m; sourceTree = "<group>"; };
|
||||
0477BDF12EBB7B850055D639 /* KBDirectionIndicatorView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBDirectionIndicatorView.h; sourceTree = "<group>"; };
|
||||
0477BDF22EBB7B850055D639 /* KBDirectionIndicatorView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBDirectionIndicatorView.m; sourceTree = "<group>"; };
|
||||
A1B2E0012EBC7AAA00000001 /* KBTopThreeView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBTopThreeView.h; sourceTree = "<group>"; };
|
||||
A1B2E0022EBC7AAA00000001 /* KBTopThreeView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBTopThreeView.m; sourceTree = "<group>"; };
|
||||
A1B2E0032EBC7AAA00000001 /* HomeHotCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HomeHotCell.h; sourceTree = "<group>"; };
|
||||
A1B2E0042EBC7AAA00000001 /* HomeHotCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HomeHotCell.m; sourceTree = "<group>"; };
|
||||
0477BDF52EBC63A80055D639 /* KBTestVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBTestVC.h; sourceTree = "<group>"; };
|
||||
0477BDF62EBC63A80055D639 /* KBTestVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBTestVC.m; sourceTree = "<group>"; };
|
||||
0477BDF82EBC66340055D639 /* HomeHeadView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HomeHeadView.h; sourceTree = "<group>"; };
|
||||
@@ -373,6 +379,10 @@
|
||||
0477BDF22EBB7B850055D639 /* KBDirectionIndicatorView.m */,
|
||||
0477BDF82EBC66340055D639 /* HomeHeadView.h */,
|
||||
0477BDF92EBC66340055D639 /* HomeHeadView.m */,
|
||||
A1B2E0012EBC7AAA00000001 /* KBTopThreeView.h */,
|
||||
A1B2E0022EBC7AAA00000001 /* KBTopThreeView.m */,
|
||||
A1B2E0032EBC7AAA00000001 /* HomeHotCell.h */,
|
||||
A1B2E0042EBC7AAA00000001 /* HomeHotCell.m */,
|
||||
);
|
||||
path = V;
|
||||
sourceTree = "<group>";
|
||||
@@ -930,6 +940,8 @@
|
||||
04C6EABF2EAF86530089C901 /* main.m in Sources */,
|
||||
04FC95CC2EB1E780007BD342 /* BaseTabBarController.m in Sources */,
|
||||
0477BDFD2EBC6A170055D639 /* HomeHotVC.m in Sources */,
|
||||
A1B2E1012EBC7AAA00000001 /* KBTopThreeView.m in Sources */,
|
||||
A1B2E1022EBC7AAA00000001 /* HomeHotCell.m in Sources */,
|
||||
0459D1B72EBA287900F2D189 /* KBSkinManager.m in Sources */,
|
||||
04FC95F42EB339C1007BD342 /* AppleSignInManager.m in Sources */,
|
||||
04C6EAC12EAF86530089C901 /* ViewController.m in Sources */,
|
||||
|
||||
20
keyBoard/Class/Home/V/HomeHotCell.h
Normal file
20
keyBoard/Class/Home/V/HomeHotCell.h
Normal file
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// HomeHotCell.h
|
||||
// keyBoard
|
||||
//
|
||||
// 自定义 cell:左侧序号与圆形头像,占位标题/副标题,右侧加入按钮。
|
||||
//
|
||||
|
||||
#import "BaseCell.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface HomeHotCell : BaseCell
|
||||
|
||||
/// 配置数据
|
||||
- (void)configWithRank:(NSInteger)rank title:(NSString *)title subtitle:(NSString *)sub joined:(BOOL)joined;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
134
keyBoard/Class/Home/V/HomeHotCell.m
Normal file
134
keyBoard/Class/Home/V/HomeHotCell.m
Normal file
@@ -0,0 +1,134 @@
|
||||
//
|
||||
// HomeHotCell.m
|
||||
// keyBoard
|
||||
//
|
||||
|
||||
#import "HomeHotCell.h"
|
||||
|
||||
@interface HomeHotCell()
|
||||
// 左侧序号
|
||||
@property (nonatomic, strong) UILabel *rankLabel;
|
||||
// 左侧圆形头像占位
|
||||
@property (nonatomic, strong) UIView *avatarView;
|
||||
// 标题
|
||||
@property (nonatomic, strong) UILabel *titleLabel;
|
||||
// 副标题
|
||||
@property (nonatomic, strong) UILabel *subLabel;
|
||||
// 右侧加入按钮(或已加入勾选)
|
||||
@property (nonatomic, strong) UIButton *actionButton;
|
||||
@end
|
||||
|
||||
@implementation HomeHotCell
|
||||
|
||||
- (void)setupUI {
|
||||
[super setupUI];
|
||||
|
||||
// 添加控件
|
||||
[self.contentView addSubview:self.rankLabel];
|
||||
[self.contentView addSubview:self.avatarView];
|
||||
[self.contentView addSubview:self.titleLabel];
|
||||
[self.contentView addSubview:self.subLabel];
|
||||
[self.contentView addSubview:self.actionButton];
|
||||
|
||||
// 布局(使用 Masonry)
|
||||
[self.rankLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.contentView).offset(16);
|
||||
make.centerY.equalTo(self.contentView);
|
||||
}];
|
||||
|
||||
[self.avatarView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.rankLabel.mas_right).offset(12);
|
||||
make.centerY.equalTo(self.contentView);
|
||||
make.width.height.mas_equalTo(52);
|
||||
}];
|
||||
|
||||
[self.actionButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerY.equalTo(self.contentView);
|
||||
make.right.equalTo(self.contentView).offset(-16);
|
||||
make.width.mas_equalTo(64);
|
||||
make.height.mas_equalTo(36);
|
||||
}];
|
||||
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.avatarView.mas_right).offset(12);
|
||||
make.top.equalTo(self.avatarView.mas_top).offset(-2);
|
||||
make.right.lessThanOrEqualTo(self.actionButton.mas_left).offset(-12);
|
||||
}];
|
||||
|
||||
[self.subLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.titleLabel);
|
||||
make.right.equalTo(self.titleLabel);
|
||||
make.bottom.equalTo(self.avatarView.mas_bottom).offset(2);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)configWithRank:(NSInteger)rank title:(NSString *)title subtitle:(NSString *)sub joined:(BOOL)joined {
|
||||
self.rankLabel.text = [NSString stringWithFormat:@"%ld", (long)rank];
|
||||
self.titleLabel.text = title ?: @"";
|
||||
self.subLabel.text = sub ?: @"";
|
||||
|
||||
if (joined) {
|
||||
// 已加入状态:灰背景、打勾
|
||||
[self.actionButton setTitle:@"✓" forState:UIControlStateNormal];
|
||||
[self.actionButton setTitleColor:[UIColor colorWithWhite:0.45 alpha:1] forState:UIControlStateNormal];
|
||||
self.actionButton.backgroundColor = [UIColor colorWithWhite:0.92 alpha:1];
|
||||
} else {
|
||||
// 可加入状态:绿色加号
|
||||
[self.actionButton setTitle:@"+" forState:UIControlStateNormal];
|
||||
[self.actionButton setTitleColor:[UIColor colorWithRed:0.20 green:0.65 blue:0.50 alpha:1.0] forState:UIControlStateNormal];
|
||||
self.actionButton.backgroundColor = [UIColor colorWithRed:0.88 green:0.97 blue:0.93 alpha:1.0];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Lazy
|
||||
|
||||
- (UILabel *)rankLabel {
|
||||
if (!_rankLabel) {
|
||||
_rankLabel = [[UILabel alloc] init];
|
||||
_rankLabel.font = [UIFont systemFontOfSize:18 weight:UIFontWeightSemibold];
|
||||
_rankLabel.textColor = [UIColor colorWithRed:0.15 green:0.55 blue:0.45 alpha:1.0];
|
||||
}
|
||||
return _rankLabel;
|
||||
}
|
||||
|
||||
- (UIView *)avatarView {
|
||||
if (!_avatarView) {
|
||||
_avatarView = [[UIView alloc] init];
|
||||
_avatarView.backgroundColor = [UIColor colorWithWhite:0.9 alpha:1];
|
||||
_avatarView.layer.cornerRadius = 26;
|
||||
_avatarView.layer.masksToBounds = YES;
|
||||
}
|
||||
return _avatarView;
|
||||
}
|
||||
|
||||
- (UILabel *)titleLabel {
|
||||
if (!_titleLabel) {
|
||||
_titleLabel = [[UILabel alloc] init];
|
||||
_titleLabel.font = [UIFont systemFontOfSize:18 weight:UIFontWeightSemibold];
|
||||
_titleLabel.textColor = [UIColor colorWithWhite:0.1 alpha:1];
|
||||
}
|
||||
return _titleLabel;
|
||||
}
|
||||
|
||||
- (UILabel *)subLabel {
|
||||
if (!_subLabel) {
|
||||
_subLabel = [[UILabel alloc] init];
|
||||
_subLabel.font = [UIFont systemFontOfSize:13];
|
||||
_subLabel.textColor = [UIColor colorWithWhite:0.5 alpha:1];
|
||||
_subLabel.numberOfLines = 1;
|
||||
}
|
||||
return _subLabel;
|
||||
}
|
||||
|
||||
- (UIButton *)actionButton {
|
||||
if (!_actionButton) {
|
||||
_actionButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
_actionButton.layer.cornerRadius = 18;
|
||||
_actionButton.layer.masksToBounds = YES;
|
||||
_actionButton.titleLabel.font = [UIFont systemFontOfSize:20 weight:UIFontWeightBold];
|
||||
}
|
||||
return _actionButton;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
21
keyBoard/Class/Home/V/KBTopThreeView.h
Normal file
21
keyBoard/Class/Home/V/KBTopThreeView.h
Normal file
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// KBTopThreeView.h
|
||||
// keyBoard
|
||||
//
|
||||
// 顶部前三名展示视图:内部横向三栏,样式参考设计图。
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/// 用于 HomeHot 顶部展示前三名的视图
|
||||
@interface KBTopThreeView : UIView
|
||||
|
||||
/// 配置三项内容(数组元素可传 @{ @"title":NSString, @"rank":@(1/2/3) })
|
||||
- (void)configWithItems:(NSArray<NSDictionary *> *)items;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
220
keyBoard/Class/Home/V/KBTopThreeView.m
Normal file
220
keyBoard/Class/Home/V/KBTopThreeView.m
Normal file
@@ -0,0 +1,220 @@
|
||||
//
|
||||
// KBTopThreeView.m
|
||||
// keyBoard
|
||||
//
|
||||
|
||||
#import "KBTopThreeView.h"
|
||||
|
||||
@interface KBTopThreeCardView : UIView
|
||||
/// 头像占位(圆形描边)
|
||||
@property (nonatomic, strong) UIView *avatarCircleView;
|
||||
/// 彩条卡片背景
|
||||
@property (nonatomic, strong) UIView *cardView;
|
||||
/// 勋章数字(1/2/3)
|
||||
@property (nonatomic, strong) UILabel *medalLabel;
|
||||
/// 标题
|
||||
@property (nonatomic, strong) UILabel *titleLabel;
|
||||
/// 底部加号按钮
|
||||
@property (nonatomic, strong) UIButton *plusButton;
|
||||
|
||||
/// 渲染
|
||||
- (void)renderWithTitle:(NSString *)title rank:(NSInteger)rank;
|
||||
@end
|
||||
|
||||
@implementation KBTopThreeCardView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame {
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
[self setupUI];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setupUI {
|
||||
// 卡片
|
||||
[self addSubview:self.cardView];
|
||||
// 头像圆圈
|
||||
[self addSubview:self.avatarCircleView];
|
||||
[self.cardView addSubview:self.medalLabel];
|
||||
[self.cardView addSubview:self.titleLabel];
|
||||
// 加号按钮
|
||||
[self addSubview:self.plusButton];
|
||||
|
||||
// 布局
|
||||
[self.avatarCircleView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self);
|
||||
make.centerX.equalTo(self);
|
||||
make.width.height.mas_equalTo(68);
|
||||
}];
|
||||
|
||||
[self.cardView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.avatarCircleView.mas_bottom).offset(-34); // 顶部悬浮重叠
|
||||
make.left.right.equalTo(self);
|
||||
make.height.mas_equalTo(146);
|
||||
}];
|
||||
|
||||
[self.medalLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.cardView).offset(34 + 15);
|
||||
make.centerX.equalTo(self.cardView);
|
||||
make.width.height.mas_equalTo(28);
|
||||
}];
|
||||
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.equalTo(self.cardView);
|
||||
make.top.equalTo(self.medalLabel.mas_bottom).offset(20);
|
||||
}];
|
||||
|
||||
[self.plusButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.cardView.mas_bottom).offset(12);
|
||||
make.centerX.equalTo(self);
|
||||
make.width.mas_equalTo(52);
|
||||
make.height.mas_equalTo(28);
|
||||
make.bottom.equalTo(self.mas_bottom); // 由外部控制总体高度
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)renderWithTitle:(NSString *)title rank:(NSInteger)rank {
|
||||
self.titleLabel.text = title.length ? title : @"";
|
||||
self.medalLabel.text = [NSString stringWithFormat:@"%ld", (long)rank];
|
||||
|
||||
// 不同名次数的配色
|
||||
UIColor *theme;
|
||||
switch (rank) {
|
||||
case 1: theme = [UIColor colorWithRed:1.00 green:0.86 blue:0.43 alpha:1.0]; break; // 金
|
||||
case 2: theme = [UIColor colorWithRed:0.68 green:0.80 blue:1.00 alpha:1.0]; break; // 蓝
|
||||
default: theme = [UIColor colorWithRed:1.00 green:0.78 blue:0.63 alpha:1.0]; break; // 橙
|
||||
}
|
||||
self.cardView.backgroundColor = theme;
|
||||
self.plusButton.backgroundColor = [theme colorWithAlphaComponent:0.3];
|
||||
|
||||
// 圆圈描边
|
||||
self.avatarCircleView.layer.borderColor = [UIColor colorWithRed:0.83 green:0.95 blue:0.27 alpha:1.0].CGColor;
|
||||
}
|
||||
|
||||
#pragma mark - Lazy
|
||||
|
||||
- (UIView *)avatarCircleView {
|
||||
if (!_avatarCircleView) {
|
||||
_avatarCircleView = [[UIView alloc] init];
|
||||
_avatarCircleView.backgroundColor = [UIColor whiteColor];
|
||||
_avatarCircleView.layer.cornerRadius = 34;
|
||||
_avatarCircleView.layer.borderWidth = 2.0;
|
||||
_avatarCircleView.layer.borderColor = [UIColor colorWithWhite:0.9 alpha:1].CGColor;
|
||||
// 可在此加入头像 UIImageView
|
||||
}
|
||||
return _avatarCircleView;
|
||||
}
|
||||
|
||||
- (UIView *)cardView {
|
||||
if (!_cardView) {
|
||||
_cardView = [[UIView alloc] init];
|
||||
_cardView.layer.cornerRadius = 14.0;
|
||||
_cardView.layer.masksToBounds = YES;
|
||||
_cardView.backgroundColor = [UIColor colorWithWhite:0.95 alpha:1];
|
||||
}
|
||||
return _cardView;
|
||||
}
|
||||
|
||||
- (UILabel *)medalLabel {
|
||||
if (!_medalLabel) {
|
||||
_medalLabel = [[UILabel alloc] init];
|
||||
_medalLabel.textAlignment = NSTextAlignmentCenter;
|
||||
_medalLabel.font = [UIFont boldSystemFontOfSize:15];
|
||||
_medalLabel.textColor = [UIColor whiteColor];
|
||||
_medalLabel.backgroundColor = [UIColor colorWithWhite:0.3 alpha:0.7];
|
||||
_medalLabel.layer.cornerRadius = 14;
|
||||
_medalLabel.layer.masksToBounds = YES;
|
||||
}
|
||||
return _medalLabel;
|
||||
}
|
||||
|
||||
- (UILabel *)titleLabel {
|
||||
if (!_titleLabel) {
|
||||
_titleLabel = [[UILabel alloc] init];
|
||||
_titleLabel.textColor = [UIColor colorWithWhite:0.1 alpha:1];
|
||||
_titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightSemibold];
|
||||
_titleLabel.textAlignment = NSTextAlignmentCenter;
|
||||
}
|
||||
return _titleLabel;
|
||||
}
|
||||
|
||||
- (UIButton *)plusButton {
|
||||
if (!_plusButton) {
|
||||
_plusButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[_plusButton setTitle:@"+" forState:UIControlStateNormal];
|
||||
[_plusButton setTitleColor:[UIColor colorWithRed:0.20 green:0.65 blue:0.50 alpha:1.0] forState:UIControlStateNormal];
|
||||
_plusButton.titleLabel.font = [UIFont systemFontOfSize:18 weight:UIFontWeightSemibold];
|
||||
_plusButton.layer.cornerRadius = 14.0;
|
||||
_plusButton.layer.masksToBounds = YES;
|
||||
}
|
||||
return _plusButton;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface KBTopThreeView()
|
||||
@property (nonatomic, strong) KBTopThreeCardView *leftCard;
|
||||
@property (nonatomic, strong) KBTopThreeCardView *centerCard;
|
||||
@property (nonatomic, strong) KBTopThreeCardView *rightCard;
|
||||
@end
|
||||
|
||||
@implementation KBTopThreeView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame {
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
self.backgroundColor = [UIColor colorWithWhite:0.98 alpha:1];
|
||||
[self setupUI];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setupUI {
|
||||
[self addSubview:self.leftCard];
|
||||
[self addSubview:self.centerCard];
|
||||
[self addSubview:self.rightCard];
|
||||
|
||||
// 横向均分布局
|
||||
[self.centerCard mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.equalTo(self);
|
||||
make.top.equalTo(self).offset(8);
|
||||
make.width.equalTo(self.mas_width).multipliedBy(1.0/3.0).offset(-12);
|
||||
}];
|
||||
[self.leftCard mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.centerCard);
|
||||
make.right.equalTo(self.centerCard.mas_left).offset(-8);
|
||||
make.width.equalTo(self.centerCard);
|
||||
}];
|
||||
[self.rightCard mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.centerCard);
|
||||
make.left.equalTo(self.centerCard.mas_right).offset(8);
|
||||
make.width.equalTo(self.centerCard);
|
||||
}];
|
||||
|
||||
// 让最右/最左卡片对齐底部,撑起本视图
|
||||
[self.leftCard mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.equalTo(self).offset(-8); }];
|
||||
[self.rightCard mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.equalTo(self).offset(-8); }];
|
||||
}
|
||||
|
||||
- (void)configWithItems:(NSArray<NSDictionary *> *)items {
|
||||
// items 顺序任意,这里按 rank 分配:1 放中间,2 左,3 右
|
||||
NSString *t1 = @"", *t2 = @"", *t3 = @"";
|
||||
for (NSDictionary *d in items) {
|
||||
NSInteger r = [d[@"rank"] integerValue];
|
||||
NSString *title = d[@"title"] ?: @"";
|
||||
if (r == 1) t1 = title;
|
||||
else if (r == 2) t2 = title;
|
||||
else if (r == 3) t3 = title;
|
||||
}
|
||||
[self.centerCard renderWithTitle:t1 rank:1];
|
||||
[self.leftCard renderWithTitle:t2 rank:2];
|
||||
[self.rightCard renderWithTitle:t3 rank:3];
|
||||
}
|
||||
|
||||
#pragma mark - Lazy
|
||||
- (KBTopThreeCardView *)leftCard { if (!_leftCard) _leftCard = [KBTopThreeCardView new]; return _leftCard; }
|
||||
- (KBTopThreeCardView *)centerCard { if (!_centerCard) _centerCard = [KBTopThreeCardView new]; return _centerCard; }
|
||||
- (KBTopThreeCardView *)rightCard { if (!_rightCard) _rightCard = [KBTopThreeCardView new]; return _rightCard; }
|
||||
|
||||
@end
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface HomeHotVC : UIViewController
|
||||
|
||||
// 列表
|
||||
@property (nonatomic, strong) BaseTableView *tableView;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -6,6 +6,18 @@
|
||||
//
|
||||
|
||||
#import "HomeHotVC.h"
|
||||
// 视图
|
||||
#import "KBTopThreeView.h"
|
||||
#import "HomeHotCell.h"
|
||||
#import <HWPanModal/HWPanModal.h>
|
||||
@interface HomeHotVC () <UITableViewDataSource, UITableViewDelegate>
|
||||
|
||||
// 顶部前三名视图
|
||||
@property (nonatomic, strong) KBTopThreeView *topThreeView;
|
||||
|
||||
@property (nonatomic, strong) NSArray<NSDictionary *> *dataSource; // 简单模拟数据
|
||||
|
||||
@end
|
||||
|
||||
@interface HomeHotVC ()
|
||||
|
||||
@@ -15,17 +27,77 @@
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view.
|
||||
self.view.backgroundColor = [UIColor whiteColor];
|
||||
|
||||
// 构建数据(演示)
|
||||
self.dataSource = @[
|
||||
@{@"rank":@4, @"title":@"Ambiguous", @"sub":@"Be Neither Too Close Nor Too Distant, Want To ...", @"joined":@NO},
|
||||
@{@"rank":@5, @"title":@"Ambiguous", @"sub":@"Be Neither Too Close Nor Too Distant, Want To ...", @"joined":@YES},
|
||||
@{@"rank":@6, @"title":@"Ambiguous", @"sub":@"Be Neither Too Close Nor Too Distant, Want To ...", @"joined":@NO},
|
||||
@{@"rank":@7, @"title":@"Ambiguous", @"sub":@"Be Neither Too Close Nor Too Distant, Want To ...", @"joined":@NO}
|
||||
];
|
||||
|
||||
// 搭建 UI
|
||||
[self.view addSubview:self.tableView];
|
||||
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.equalTo(self.view);
|
||||
}];
|
||||
|
||||
// 顶部前三名作为 tableHeaderView(注意:tableHeaderView 需设定明确高度)
|
||||
CGFloat headerH = 280.0;
|
||||
self.topThreeView = [[KBTopThreeView alloc] initWithFrame:CGRectMake(0, 0, KB_SCREEN_WIDTH, headerH)];
|
||||
// 示例配置:三个条目的标题
|
||||
[self.topThreeView configWithItems:@[
|
||||
@{@"title":@"High EQ", @"rank":@1},
|
||||
@{@"title":@"Flirt Girls", @"rank":@2},
|
||||
@{@"title":@"Humorous", @"rank":@3}
|
||||
]];
|
||||
self.tableView.tableHeaderView = self.topThreeView;
|
||||
}
|
||||
|
||||
/*
|
||||
#pragma mark - Navigation
|
||||
#pragma mark - UITableViewDataSource
|
||||
|
||||
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
||||
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
||||
// Get the new view controller using [segue destinationViewController].
|
||||
// Pass the selected object to the new view controller.
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||
return self.dataSource.count;
|
||||
}
|
||||
*/
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
HomeHotCell *cell = [tableView dequeueReusableCellWithIdentifier:HomeHotCell.reuseId forIndexPath:indexPath];
|
||||
NSDictionary *item = self.dataSource[indexPath.row];
|
||||
// 配置 cell
|
||||
[cell configWithRank:[item[@"rank"] integerValue]
|
||||
title:item[@"title"]
|
||||
subtitle:item[@"sub"]
|
||||
joined:[item[@"joined"] boolValue]];
|
||||
return cell;
|
||||
}
|
||||
|
||||
#pragma mark - UITableViewDelegate
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
return 84.0;
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
||||
}
|
||||
|
||||
#pragma mark - Lazy
|
||||
|
||||
- (BaseTableView *)tableView {
|
||||
if (!_tableView) {
|
||||
// 使用 BaseTableView,统一默认配置
|
||||
_tableView = [[BaseTableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
|
||||
_tableView.dataSource = self;
|
||||
_tableView.delegate = self;
|
||||
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone; // 设计为卡片式,去掉系统分割线
|
||||
_tableView.showsVerticalScrollIndicator = NO;
|
||||
_tableView.contentInset = UIEdgeInsetsMake(8, 0, KB_SafeAreaBottom(), 0);
|
||||
[_tableView registerClass:HomeHotCell.class forCellReuseIdentifier:HomeHotCell.reuseId];
|
||||
}
|
||||
return _tableView;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@@ -62,8 +62,8 @@
|
||||
}
|
||||
|
||||
- (void)didChangeTransitionToState:(PresentationState)state {
|
||||
// 每次状态切换完成后刷新朝向
|
||||
[self.indicator applyPresentationState:state];
|
||||
// // 每次状态切换完成后刷新朝向
|
||||
// [self.indicator applyPresentationState:state];
|
||||
}
|
||||
|
||||
- (PanModalHeight)shortFormHeight {
|
||||
@@ -86,33 +86,43 @@
|
||||
return NO; // 在 short 状态禁止继续往下拉(锁住最小高度)
|
||||
}
|
||||
|
||||
/// 允许时间穿透
|
||||
- (BOOL)allowsTouchEventsPassingThroughTransitionView {
|
||||
return YES;
|
||||
}
|
||||
|
||||
-(BOOL)shouldAutoSetPanScrollContentInset{
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
||||
- (UIScrollView *)panScrollable {
|
||||
return self.hotVC.tableView;
|
||||
}
|
||||
|
||||
// 可选:完全不允许拖拽关闭(避免被拉到底消失)
|
||||
- (BOOL)allowsDragToDismiss {
|
||||
return NO;
|
||||
}
|
||||
|
||||
//
|
||||
//- (BOOL)showDragIndicator{
|
||||
// return NO;
|
||||
//}
|
||||
|
||||
//
|
||||
// 点背景不关闭
|
||||
- (BOOL)allowsTapBackgroundToDismiss {
|
||||
return NO;
|
||||
}
|
||||
|
||||
// 出现时不做上推动画(瞬时到位)
|
||||
- (NSTimeInterval)transitionDuration {
|
||||
return 0;
|
||||
}
|
||||
// 出现时不做上推动画(瞬时到位)开了下拉动画有问题
|
||||
//- (NSTimeInterval)transitionDuration {
|
||||
// return 0;
|
||||
//}
|
||||
|
||||
// 可选:关闭触觉反馈,避免出现时的轻微震动
|
||||
- (BOOL)isHapticFeedbackEnabled {
|
||||
return NO;
|
||||
}
|
||||
//// 可选:关闭触觉反馈,避免出现时的轻微震动
|
||||
//- (BOOL)isHapticFeedbackEnabled {
|
||||
// return NO;
|
||||
//}
|
||||
|
||||
|
||||
#pragma mark - UI
|
||||
|
||||
@@ -18,14 +18,17 @@
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
self.view.backgroundColor = [UIColor whiteColor];
|
||||
CGFloat topV = KBFit(500);
|
||||
self.view.backgroundColor = [UIColor yellowColor];
|
||||
CGFloat topV = (500);
|
||||
|
||||
[self.view addSubview:self.headView];
|
||||
[self setupMas:topV];
|
||||
// 创建sheetVC
|
||||
HomeSheetVC *vc = [[HomeSheetVC alloc] init];
|
||||
vc.minHeight = KB_SCREEN_HEIGHT - topV - 30;
|
||||
if (<#condition#>) {
|
||||
<#statements#>
|
||||
}
|
||||
vc.minHeight = KB_SCREEN_HEIGHT - topV;
|
||||
vc.topInset = 100;
|
||||
[self presentPanModal:vc];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user