73 lines
2.6 KiB
Objective-C
73 lines
2.6 KiB
Objective-C
//
|
||
// BaseNavigationController.m
|
||
// xplan-ios
|
||
//
|
||
// Created by zu on 2021/9/7.
|
||
//
|
||
|
||
#import "BaseNavigationController.h"
|
||
///Tool
|
||
#import "ThemeColor.h"
|
||
|
||
@interface BaseNavigationController ()
|
||
|
||
@end
|
||
|
||
@implementation BaseNavigationController
|
||
|
||
- (void)viewDidLoad {
|
||
[super viewDidLoad];
|
||
if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
|
||
self.interactivePopGestureRecognizer.delegate = self;
|
||
}
|
||
[self themeConfig];
|
||
}
|
||
|
||
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
|
||
if(self.topViewController == viewController) return;
|
||
if (self.childViewControllers.count > 0) {
|
||
viewController.hidesBottomBarWhenPushed = YES;
|
||
UIBarButtonItem *leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"common_nav_back"] style:UIBarButtonItemStyleDone target:self action:@selector(backClick)];
|
||
leftBarButtonItem.tintColor = [ThemeColor mainTextColor];
|
||
viewController.navigationItem.leftBarButtonItem = leftBarButtonItem;
|
||
}
|
||
viewController.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
|
||
|
||
[super pushViewController:viewController animated:animated];
|
||
}
|
||
|
||
- (void)backClick{
|
||
[self popViewControllerAnimated:YES];
|
||
}
|
||
|
||
- (void)themeConfig {
|
||
self.navigationBar.shadowImage = [[UIImage alloc] init];
|
||
self.navigationBar.barTintColor = [ThemeColor appBackgroundColor];
|
||
self.navigationBar.tintColor = [UIColor whiteColor];
|
||
self.navigationBar.translucent = NO;
|
||
self.view.backgroundColor = [ThemeColor appBackgroundColor];
|
||
[self.navigationBar setTitleTextAttributes:@{
|
||
NSFontAttributeName:[UIFont systemFontOfSize:18 weight:UIFontWeightMedium],
|
||
NSForegroundColorAttributeName:[ThemeColor mainTextColor]
|
||
}];
|
||
|
||
/// scrollEdgeAppearance 属性iOS15 强制适用于 所有导航器 如果为nil 则使用 standardAppearance属性中的设置,并修改为使用透明背景 @fengshuo
|
||
if (@available(iOS 15.0, *)) {
|
||
UINavigationBarAppearance *appearance = [UINavigationBarAppearance new];
|
||
appearance.titleTextAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:18 weight:UIFontWeightMedium],
|
||
NSForegroundColorAttributeName:[ThemeColor mainTextColor]};
|
||
appearance.backgroundColor = [ThemeColor appCellBackgroundColor];
|
||
self.navigationBar.standardAppearance = appearance;
|
||
self.navigationBar.scrollEdgeAppearance = appearance;
|
||
}
|
||
}
|
||
|
||
#pragma mark - UIGestureRecognizerDelegate
|
||
|
||
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
|
||
return YES;
|
||
}
|
||
|
||
|
||
@end
|