Files
keyboard/keyBoard/Class/Base/VC/BaseNavigationController.m
2025-11-03 19:00:47 +08:00

48 lines
1.6 KiB
Objective-C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// BaseNavigationController.m
// keyBoard
//
// Created by Mac on 2025/10/29.
//
#import "BaseNavigationController.h"
@interface BaseNavigationController ()
@end
@implementation BaseNavigationController
- (void)viewDidLoad {
[super viewDidLoad];
// 统一返回箭头样式与颜色
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];
}
@end