Files
yinmeng-ios/xplan-ios/Base/UI/BaseNavigationController.m

73 lines
2.6 KiB
Mathematica
Raw Normal View History

2021-09-07 23:05:43 +08:00
//
// BaseNavigationController.m
// xplan-ios
//
// Created by zu on 2021/9/7.
//
#import "BaseNavigationController.h"
///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];
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
}];
/// 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];
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-09-07 23:05:43 +08:00
@end