3
This commit is contained in:
@@ -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