2021-09-07 23:05:43 +08:00
|
|
|
|
//
|
|
|
|
|
// BaseNavigationController.m
|
|
|
|
|
// xplan-ios
|
|
|
|
|
//
|
|
|
|
|
// Created by zu on 2021/9/7.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#import "BaseNavigationController.h"
|
2021-09-13 14:22:51 +08:00
|
|
|
|
///Tool
|
|
|
|
|
#import "ThemeColor.h"
|
2021-09-07 23:05:43 +08:00
|
|
|
|
|
|
|
|
|
@interface BaseNavigationController ()
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@implementation BaseNavigationController
|
|
|
|
|
|
|
|
|
|
- (void)viewDidLoad {
|
|
|
|
|
[super viewDidLoad];
|
2021-12-17 19:31:26 +08:00
|
|
|
|
if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
|
|
|
|
|
self.interactivePopGestureRecognizer.delegate = self;
|
|
|
|
|
}
|
2021-09-07 23:05:43 +08:00
|
|
|
|
[self themeConfig];
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-09 19:18:47 +08:00
|
|
|
|
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
|
2021-09-16 17:21:52 +08:00
|
|
|
|
if(self.topViewController == viewController) return;
|
|
|
|
|
if (self.childViewControllers.count > 0) {
|
|
|
|
|
viewController.hidesBottomBarWhenPushed = YES;
|
2021-12-17 19:31:26 +08:00
|
|
|
|
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;
|
2021-09-16 17:21:52 +08:00
|
|
|
|
}
|
2021-09-09 19:18:47 +08:00
|
|
|
|
viewController.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
|
2021-09-16 17:21:52 +08:00
|
|
|
|
|
2021-09-09 19:18:47 +08:00
|
|
|
|
[super pushViewController:viewController animated:animated];
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-17 19:31:26 +08:00
|
|
|
|
- (void)backClick{
|
|
|
|
|
[self popViewControllerAnimated:YES];
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-07 23:05:43 +08:00
|
|
|
|
- (void)themeConfig {
|
|
|
|
|
self.navigationBar.shadowImage = [[UIImage alloc] init];
|
2021-09-13 14:22:51 +08:00
|
|
|
|
self.navigationBar.barTintColor = [ThemeColor appBackgroundColor];
|
2021-09-07 23:05:43 +08:00
|
|
|
|
self.navigationBar.tintColor = [UIColor whiteColor];
|
|
|
|
|
self.navigationBar.translucent = NO;
|
2022-04-21 16:10:28 +08:00
|
|
|
|
self.view.backgroundColor = [ThemeColor appBackgroundColor];
|
2021-09-07 23:05:43 +08:00
|
|
|
|
[self.navigationBar setTitleTextAttributes:@{
|
2021-09-09 19:18:47 +08:00
|
|
|
|
NSFontAttributeName:[UIFont systemFontOfSize:18 weight:UIFontWeightMedium],
|
2021-12-17 19:31:26 +08:00
|
|
|
|
NSForegroundColorAttributeName:[ThemeColor mainTextColor]
|
2021-09-07 23:05:43 +08:00
|
|
|
|
}];
|
2021-11-30 18:18:12 +08:00
|
|
|
|
|
|
|
|
|
/// scrollEdgeAppearance 属性iOS15 强制适用于 所有导航器 如果为nil 则使用 standardAppearance属性中的设置,并修改为使用透明背景 @fengshuo
|
|
|
|
|
if (@available(iOS 15.0, *)) {
|
|
|
|
|
UINavigationBarAppearance *appearance = [UINavigationBarAppearance new];
|
|
|
|
|
appearance.titleTextAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:18 weight:UIFontWeightMedium],
|
2021-12-17 19:31:26 +08:00
|
|
|
|
NSForegroundColorAttributeName:[ThemeColor mainTextColor]};
|
|
|
|
|
appearance.backgroundColor = [ThemeColor appCellBackgroundColor];
|
2021-11-30 18:18:12 +08:00
|
|
|
|
self.navigationBar.standardAppearance = appearance;
|
|
|
|
|
self.navigationBar.scrollEdgeAppearance = appearance;
|
|
|
|
|
}
|
2021-09-07 23:05:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-17 19:31:26 +08:00
|
|
|
|
#pragma mark - UIGestureRecognizerDelegate
|
|
|
|
|
|
|
|
|
|
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
|
|
|
|
|
return YES;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-30 18:18:12 +08:00
|
|
|
|
|
2021-09-07 23:05:43 +08:00
|
|
|
|
@end
|