From cac2f13b8848732187a9d34dcd9482923e2db761 Mon Sep 17 00:00:00 2001 From: CodeST <694468528@qq.com> Date: Mon, 3 Nov 2025 19:00:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BC=95=E5=AF=BC=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Class/Base/VC/BaseNavigationController.m | 21 ++++++++++++++++++- keyBoard/Class/Guard/VC/KBGuideVC.m | 15 +++++++------ keyBoard/VC/KBPermissionViewController.h | 1 + keyBoard/VC/KBPermissionViewController.m | 2 -- 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/keyBoard/Class/Base/VC/BaseNavigationController.m b/keyBoard/Class/Base/VC/BaseNavigationController.m index a882343..3d55ecb 100644 --- a/keyBoard/Class/Base/VC/BaseNavigationController.m +++ b/keyBoard/Class/Base/VC/BaseNavigationController.m @@ -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]; } diff --git a/keyBoard/Class/Guard/VC/KBGuideVC.m b/keyBoard/Class/Guard/VC/KBGuideVC.m index b3ba9dd..32f4b4b 100644 --- a/keyBoard/Class/Guard/VC/KBGuideVC.m +++ b/keyBoard/Class/Guard/VC/KBGuideVC.m @@ -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]; }]; diff --git a/keyBoard/VC/KBPermissionViewController.h b/keyBoard/VC/KBPermissionViewController.h index d3d91e0..90bced0 100644 --- a/keyBoard/VC/KBPermissionViewController.h +++ b/keyBoard/VC/KBPermissionViewController.h @@ -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 diff --git a/keyBoard/VC/KBPermissionViewController.m b/keyBoard/VC/KBPermissionViewController.m index dc1bb40..6ba3ed3 100644 --- a/keyBoard/VC/KBPermissionViewController.m +++ b/keyBoard/VC/KBPermissionViewController.m @@ -6,10 +6,8 @@ // #import "KBPermissionViewController.h" -#import @interface KBPermissionViewController () -@property (nonatomic, strong) UIButton *backButton; // 左上角返回 @property (nonatomic, strong) UILabel *titleLabel; // 标题 @property (nonatomic, strong) UILabel *tipsLabel; // 步骤提示 @property (nonatomic, strong) UIView *cardView; // 中部卡片