添加HWPanModal和FLAnimatedImage
This commit is contained in:
18
keyBoard/Class/Home/VC/HomeSheetVC.h
Normal file
18
keyBoard/Class/Home/VC/HomeSheetVC.h
Normal file
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// HomeSheetVC.h
|
||||
// keyBoard
|
||||
//
|
||||
// Created by Mac on 2025/11/5.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <HWPanModal/HWPanModal.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface HomeSheetVC : UIViewController<HWPanModalPresentable>
|
||||
@property (nonatomic, assign) CGFloat minHeight; // 例如 150
|
||||
@property (nonatomic, assign) CGFloat topInset; // 例如 100
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
73
keyBoard/Class/Home/VC/HomeSheetVC.m
Normal file
73
keyBoard/Class/Home/VC/HomeSheetVC.m
Normal file
@@ -0,0 +1,73 @@
|
||||
//
|
||||
// HomeSheetVC.m
|
||||
// keyBoard
|
||||
//
|
||||
// Created by Mac on 2025/11/5.
|
||||
//
|
||||
|
||||
#import "HomeSheetVC.h"
|
||||
#import "KBDirectionIndicatorView.h"
|
||||
|
||||
@interface HomeSheetVC ()
|
||||
@property (nonatomic, strong) KBDirectionIndicatorView *indicator;
|
||||
@end
|
||||
|
||||
@implementation HomeSheetVC
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view.
|
||||
self.view.backgroundColor = [UIColor redColor];
|
||||
}
|
||||
|
||||
- (UIView<HWPanModalIndicatorProtocol> *)customIndicatorView {
|
||||
if (!_indicator) _indicator = [KBDirectionIndicatorView new];
|
||||
return _indicator;
|
||||
}
|
||||
|
||||
- (void)panModalTransitionDidFinish {
|
||||
// 初次展示后按当前状态设定一次朝向
|
||||
[self.indicator applyPresentationState:self.hw_presentationState];
|
||||
}
|
||||
|
||||
- (void)didChangeTransitionToState:(PresentationState)state {
|
||||
// 每次状态切换完成后刷新朝向
|
||||
[self.indicator applyPresentationState:state];
|
||||
}
|
||||
|
||||
- (PanModalHeight)shortFormHeight {
|
||||
return PanModalHeightMake(PanModalHeightTypeContent, self.minHeight ?: 300);
|
||||
}
|
||||
|
||||
- (PanModalHeight)longFormHeight {
|
||||
return PanModalHeightMake(PanModalHeightTypeMaxTopInset, self.topInset ?: 100);
|
||||
}
|
||||
|
||||
- (PresentationState)originPresentationState {
|
||||
return PresentationStateShort; // 初始就以最小高度展示
|
||||
}
|
||||
|
||||
- (BOOL)anchorModalToLongForm {
|
||||
return YES; // 到 long 后不再继续往上拖
|
||||
}
|
||||
|
||||
- (BOOL)allowsPullDownWhenShortState {
|
||||
return NO; // 在 short 状态禁止继续往下拉(锁住最小高度)
|
||||
}
|
||||
|
||||
// 可选:完全不允许拖拽关闭(避免被拉到底消失)
|
||||
- (BOOL)allowsDragToDismiss {
|
||||
return NO;
|
||||
}
|
||||
|
||||
//- (BOOL)showDragIndicator{
|
||||
// return NO;
|
||||
//}
|
||||
|
||||
// 点背景不关闭
|
||||
- (BOOL)allowsTapBackgroundToDismiss {
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
@@ -8,6 +8,7 @@
|
||||
#import "HomeVC.h"
|
||||
#import "KBGuideVC.h"
|
||||
#import "KBLangTestVC.h"
|
||||
#import "HomeSheetVC.h"
|
||||
|
||||
@interface HomeVC () <UITableViewDelegate, UITableViewDataSource>
|
||||
@property (nonatomic, strong) UITextView *textView; // 作为表头,保持原有键盘测试
|
||||
@@ -21,37 +22,42 @@
|
||||
[super viewDidLoad];
|
||||
self.view.backgroundColor = [UIColor whiteColor];
|
||||
|
||||
CGFloat width = [UIScreen mainScreen].bounds.size.width;
|
||||
UIView *header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, width, 220)];
|
||||
CGRect frame = CGRectMake(16, 16, width - 32, 188);
|
||||
self.textView = [[UITextView alloc] initWithFrame:frame];
|
||||
self.textView.text = KBLocalized(@"home_input_placeholder");
|
||||
self.textView.layer.borderColor = [UIColor blackColor].CGColor;
|
||||
self.textView.layer.borderWidth = 0.5;
|
||||
[header addSubview:self.textView];
|
||||
|
||||
// 列表
|
||||
self.tableView = [[BaseTableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleInsetGrouped];
|
||||
self.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
||||
self.tableView.delegate = self;
|
||||
self.tableView.dataSource = self;
|
||||
self.tableView.tableHeaderView = header;
|
||||
[self.view addSubview:self.tableView];
|
||||
|
||||
self.items = @[ KBLocalized(@"home_item_lang_test"), KBLocalized(@"home_item_keyboard_permission"), @"皮肤中心" ];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{ [self.textView becomeFirstResponder]; });
|
||||
|
||||
[[KBNetworkManager shared] GET:@"app/config" parameters:nil headers:nil completion:^(id _Nullable jsonOrData, NSURLResponse * _Nullable response, NSError * _Nullable error) {
|
||||
NSLog(@"====");
|
||||
}];
|
||||
// CGFloat width = [UIScreen mainScreen].bounds.size.width;
|
||||
// UIView *header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, width, 220)];
|
||||
// CGRect frame = CGRectMake(16, 16, width - 32, 188);
|
||||
// self.textView = [[UITextView alloc] initWithFrame:frame];
|
||||
// self.textView.text = KBLocalized(@"home_input_placeholder");
|
||||
// self.textView.layer.borderColor = [UIColor blackColor].CGColor;
|
||||
// self.textView.layer.borderWidth = 0.5;
|
||||
// [header addSubview:self.textView];
|
||||
//
|
||||
// // 列表
|
||||
// self.tableView = [[BaseTableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleInsetGrouped];
|
||||
// self.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
||||
// self.tableView.delegate = self;
|
||||
// self.tableView.dataSource = self;
|
||||
// self.tableView.tableHeaderView = header;
|
||||
// [self.view addSubview:self.tableView];
|
||||
//
|
||||
// self.items = @[ KBLocalized(@"home_item_lang_test"), KBLocalized(@"home_item_keyboard_permission"), @"皮肤中心" ];
|
||||
//
|
||||
// dispatch_async(dispatch_get_main_queue(), ^{ [self.textView becomeFirstResponder]; });
|
||||
//
|
||||
// [[KBNetworkManager shared] GET:@"app/config" parameters:nil headers:nil completion:^(id _Nullable jsonOrData, NSURLResponse * _Nullable response, NSError * _Nullable error) {
|
||||
// NSLog(@"====");
|
||||
// }];
|
||||
|
||||
HomeSheetVC *vc = [HomeSheetVC new];
|
||||
vc.minHeight = 300;
|
||||
vc.topInset = 100;
|
||||
[self presentPanModal:vc];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated{
|
||||
[super viewWillAppear:animated];
|
||||
self.title = KBLocalized(@"home_title");
|
||||
self.items = @[ KBLocalized(@"home_item_lang_test"), KBLocalized(@"home_item_keyboard_permission"), @"皮肤中心" ];
|
||||
[self.tableView reloadData];
|
||||
// self.title = KBLocalized(@"home_title");
|
||||
// self.items = @[ KBLocalized(@"home_item_lang_test"), KBLocalized(@"home_item_keyboard_permission"), @"皮肤中心" ];
|
||||
// [self.tableView reloadData];
|
||||
}
|
||||
|
||||
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
|
||||
|
||||
Reference in New Issue
Block a user