修改引导逻辑
This commit is contained in:
@@ -15,12 +15,31 @@
|
|||||||
|
|
||||||
- (void)viewDidLoad {
|
- (void)viewDidLoad {
|
||||||
[super 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{
|
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
|
||||||
if (self.viewControllers.count > 0) {
|
if (self.viewControllers.count > 0) {
|
||||||
viewController.hidesBottomBarWhenPushed = true;
|
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];
|
[super pushViewController:viewController animated:animated];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ typedef NS_ENUM(NSInteger, KBGuideItemType) {
|
|||||||
|
|
||||||
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
make.top.left.right.equalTo(self.view);
|
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) {
|
[self.inputBar mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
@@ -108,22 +108,23 @@ typedef NS_ENUM(NSInteger, KBGuideItemType) {
|
|||||||
|
|
||||||
[self kb_preparePermissionOverlayIfNeeded];
|
[self kb_preparePermissionOverlayIfNeeded];
|
||||||
BOOL show = needGuide;
|
BOOL show = needGuide;
|
||||||
[UIView performWithoutAnimation:^{
|
// [UIView performWithoutAnimation:^{
|
||||||
self.permVC.view.hidden = !show;
|
self.permVC.view.hidden = !show;
|
||||||
}];
|
// }];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 提前创建权限引导页覆盖层(仅一次)
|
/// 提前创建权限引导页覆盖层(仅一次)
|
||||||
- (void)kb_preparePermissionOverlayIfNeeded {
|
- (void)kb_preparePermissionOverlayIfNeeded {
|
||||||
if (self.permVC) return;
|
if (self.permVC) return;
|
||||||
KBPermissionViewController *guide = [KBPermissionViewController new];
|
KBPermissionViewController *guide = [KBPermissionViewController new];
|
||||||
guide.modalPresentationStyle = UIModalPresentationFullScreen; // 仅用于内部布局,不会真正 present
|
// guide.modalPresentationStyle = UIModalPresentationFullScreen; // 仅用于内部布局,不会真正 present
|
||||||
KBWeakSelf;
|
KBWeakSelf;
|
||||||
guide.backHandler = ^{ [weakSelf.navigationController popViewControllerAnimated:YES]; };
|
guide.backHandler = ^{ [weakSelf.navigationController popViewControllerAnimated:YES]; };
|
||||||
self.permVC = guide;
|
self.permVC = guide;
|
||||||
|
guide.backButton.hidden = true;
|
||||||
[self addChildViewController:guide];
|
[self addChildViewController:guide];
|
||||||
[self.view addSubview:guide.view];
|
[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 didMoveToParentViewController:self];
|
||||||
guide.view.hidden = YES; // 初始隐藏
|
guide.view.hidden = YES; // 初始隐藏
|
||||||
}
|
}
|
||||||
@@ -172,12 +173,10 @@ typedef NS_ENUM(NSInteger, KBGuideItemType) {
|
|||||||
self.inputBarBottom.offset = offset;
|
self.inputBarBottom.offset = offset;
|
||||||
|
|
||||||
[UIView animateWithDuration:duration delay:0 options:curve animations:^{
|
[UIView animateWithDuration:duration delay:0 options:curve animations:^{
|
||||||
[self.view layoutIfNeeded];
|
|
||||||
// 留出输入栏高度的 contentInset,避免最后一行被遮挡
|
|
||||||
UIEdgeInsets inset = self.tableView.contentInset;
|
UIEdgeInsets inset = self.tableView.contentInset;
|
||||||
inset.bottom = 52 + MAX(kbHeight - safeBtm, 0);
|
inset.bottom = 52 + MAX(kbHeight - safeBtm, 0);
|
||||||
self.tableView.contentInset = inset;
|
self.tableView.contentInset = inset;
|
||||||
self.tableView.scrollIndicatorInsets = inset;
|
// self.tableView.scrollIndicatorInsets = inset;
|
||||||
} completion:^(BOOL finished) {
|
} completion:^(BOOL finished) {
|
||||||
[self scrollToBottomAnimated:YES];
|
[self scrollToBottomAnimated:YES];
|
||||||
}];
|
}];
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
/// 点击页面左上角“返回”时回调。用于让调用方(如 KBGuideVC)一起退出等自定义行为。
|
/// 点击页面左上角“返回”时回调。用于让调用方(如 KBGuideVC)一起退出等自定义行为。
|
||||||
/// 注意:避免与按钮 action `onBack` 重名,故命名为 backHandler。
|
/// 注意:避免与按钮 action `onBack` 重名,故命名为 backHandler。
|
||||||
@property (nonatomic, copy, nullable) void (^backHandler)(void);
|
@property (nonatomic, copy, nullable) void (^backHandler)(void);
|
||||||
|
@property (nonatomic, strong) UIButton *backButton; // 左上角返回
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,8 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import "KBPermissionViewController.h"
|
#import "KBPermissionViewController.h"
|
||||||
#import <TargetConditionals.h>
|
|
||||||
|
|
||||||
@interface KBPermissionViewController ()
|
@interface KBPermissionViewController ()
|
||||||
@property (nonatomic, strong) UIButton *backButton; // 左上角返回
|
|
||||||
@property (nonatomic, strong) UILabel *titleLabel; // 标题
|
@property (nonatomic, strong) UILabel *titleLabel; // 标题
|
||||||
@property (nonatomic, strong) UILabel *tipsLabel; // 步骤提示
|
@property (nonatomic, strong) UILabel *tipsLabel; // 步骤提示
|
||||||
@property (nonatomic, strong) UIView *cardView; // 中部卡片
|
@property (nonatomic, strong) UIView *cardView; // 中部卡片
|
||||||
|
|||||||
Reference in New Issue
Block a user