修改引导逻辑

This commit is contained in:
2025-11-03 19:00:47 +08:00
parent edf88721da
commit cac2f13b88
4 changed files with 28 additions and 11 deletions

View File

@@ -15,12 +15,31 @@
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
//
UIImage *backImg = [UIImage imageNamed:@"back_black_icon"];
if (backImg) {
// 使mask
self.navigationBar.backIndicatorImage = backImg;
self.navigationBar.backIndicatorTransitionMaskImage = backImg;
}
self.navigationBar.tintColor = [UIColor blackColor]; // /
// iOS 14+
if (@available(iOS 14.0, *)) {
self.navigationBar.topItem.backButtonDisplayMode = UINavigationItemBackButtonDisplayModeMinimal;
}
}
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
if (self.viewControllers.count > 0) {
viewController.hidesBottomBarWhenPushed = true;
//
UIViewController *prev = self.topViewController;
if (@available(iOS 14.0, *)) {
prev.navigationItem.backButtonDisplayMode = UINavigationItemBackButtonDisplayModeMinimal;
} else {
prev.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
}
}
[super pushViewController:viewController animated:animated];
}

View File

@@ -46,7 +46,7 @@ typedef NS_ENUM(NSInteger, KBGuideItemType) {
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.left.right.equalTo(self.view);
make.bottom.equalTo(self.inputBar.mas_top);
make.bottom.equalTo(self.view);
}];
[self.inputBar mas_makeConstraints:^(MASConstraintMaker *make) {
@@ -108,22 +108,23 @@ typedef NS_ENUM(NSInteger, KBGuideItemType) {
[self kb_preparePermissionOverlayIfNeeded];
BOOL show = needGuide;
[UIView performWithoutAnimation:^{
// [UIView performWithoutAnimation:^{
self.permVC.view.hidden = !show;
}];
// }];
}
///
- (void)kb_preparePermissionOverlayIfNeeded {
if (self.permVC) return;
KBPermissionViewController *guide = [KBPermissionViewController new];
guide.modalPresentationStyle = UIModalPresentationFullScreen; // present
// guide.modalPresentationStyle = UIModalPresentationFullScreen; // present
KBWeakSelf;
guide.backHandler = ^{ [weakSelf.navigationController popViewControllerAnimated:YES]; };
self.permVC = guide;
guide.backButton.hidden = true;
[self addChildViewController:guide];
[self.view addSubview:guide.view];
[guide.view mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.equalTo(self.view); }];
// [guide.view mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.equalTo(self.view); }];
[guide didMoveToParentViewController:self];
guide.view.hidden = YES; //
}
@@ -172,12 +173,10 @@ typedef NS_ENUM(NSInteger, KBGuideItemType) {
self.inputBarBottom.offset = offset;
[UIView animateWithDuration:duration delay:0 options:curve animations:^{
[self.view layoutIfNeeded];
// contentInset
UIEdgeInsets inset = self.tableView.contentInset;
inset.bottom = 52 + MAX(kbHeight - safeBtm, 0);
self.tableView.contentInset = inset;
self.tableView.scrollIndicatorInsets = inset;
// self.tableView.scrollIndicatorInsets = inset;
} completion:^(BOOL finished) {
[self scrollToBottomAnimated:YES];
}];

View File

@@ -14,6 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
/// 点击页面左上角“返回”时回调。用于让调用方(如 KBGuideVC一起退出等自定义行为。
/// 注意:避免与按钮 action `onBack` 重名,故命名为 backHandler。
@property (nonatomic, copy, nullable) void (^backHandler)(void);
@property (nonatomic, strong) UIButton *backButton; // 左上角返回
@end

View File

@@ -6,10 +6,8 @@
//
#import "KBPermissionViewController.h"
#import <TargetConditionals.h>
@interface KBPermissionViewController ()
@property (nonatomic, strong) UIButton *backButton; //
@property (nonatomic, strong) UILabel *titleLabel; //
@property (nonatomic, strong) UILabel *tipsLabel; //
@property (nonatomic, strong) UIView *cardView; //