Files
real-e-party-iOS/YuMi/Structure/Base/BaseNavigationController.m
edwinQQQ a35a711be6 chore: Initial clean commit
- Removed YuMi/Library/ (138 MB, not tracked)
- Removed YuMi/Resources/ (23 MB, not tracked)
- Removed old version assets (566 files, not tracked)
- Excluded Pods/, xcuserdata/ and other build artifacts
- Clean repository optimized for company server deployment
2025-10-09 16:19:14 +08:00

92 lines
3.7 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
// YUMI
//
// Created by zu on 2021/9/7.
//
#import "BaseNavigationController.h"
///Tool
#import "DJDKMIMOMColor.h"
@interface BaseNavigationController ()<UIGestureRecognizerDelegate>
@end
@implementation BaseNavigationController
-(void)dealloc{
[[NSNotificationCenter defaultCenter]removeObserver:self];
}
- (void)viewDidLoad {
[super viewDidLoad];
if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.interactivePopGestureRecognizer.delegate = self;
}
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(switchLanguage) name:@"kNavViewUpdateWhenLanguageUpdate" object:nil];
[self themeConfig];
if(isMSRTL()){
self.navigationBar.semanticContentAttribute = UISemanticContentAttributeForceRightToLeft;;
self.view.semanticContentAttribute = UISemanticContentAttributeForceRightToLeft;
}else{
self.navigationBar.semanticContentAttribute = UISemanticContentAttributeForceLeftToRight;;
self.view.semanticContentAttribute = UISemanticContentAttributeForceLeftToRight;
}
}
-(void)switchLanguage{
if(isMSRTL()){
self.navigationBar.semanticContentAttribute = UISemanticContentAttributeForceRightToLeft;
self.view.semanticContentAttribute = UISemanticContentAttributeForceRightToLeft;
}else{
self.navigationBar.semanticContentAttribute = UISemanticContentAttributeForceLeftToRight;
self.view.semanticContentAttribute = UISemanticContentAttributeForceLeftToRight;
}
}
- (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"]ms_SetImageForRTL] style:UIBarButtonItemStyleDone target:self action:@selector(backClick)];
leftBarButtonItem.tintColor = [DJDKMIMOMColor 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 = [DJDKMIMOMColor appBackgroundColor];
self.navigationBar.tintColor = [UIColor whiteColor];
self.navigationBar.translucent = NO;
self.view.backgroundColor = [DJDKMIMOMColor appBackgroundColor];
[self.navigationBar setTitleTextAttributes:@{
NSFontAttributeName:[UIFont systemFontOfSize:18 weight:UIFontWeightMedium],
NSForegroundColorAttributeName:[DJDKMIMOMColor mainTextColor]
}];
/// scrollEdgeAppearance 属性iOS15 强制适用于 所有导航器 如果为nil 则使用 standardAppearance属性中的设置并修改为使用透明背景 @fengshuo
if (@available(iOS 15.0, *)) {
UINavigationBarAppearance *appearance = [UINavigationBarAppearance new];
appearance.titleTextAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:18 weight:UIFontWeightMedium],
NSForegroundColorAttributeName:[DJDKMIMOMColor mainTextColor]};
appearance.backgroundColor = [DJDKMIMOMColor appCellBackgroundColor];
self.navigationBar.standardAppearance = appearance;
self.navigationBar.scrollEdgeAppearance = appearance;
}
}
#pragma mark - UIGestureRecognizerDelegate
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
return YES;
}
@end