iOS 15 , 导航异常问题
导航进入下一个页面时,导航栏变透明,看到上一个页面标题按钮
#import "GCJNavigationController.h"
#import "GCJBaseViewController.h"
#import "Defined.h"
@interface GCJNavigationController ()
@property (nonatomic, assign) BOOL shouldIgnorePushingViewControllers;
@end
@implementation GCJNavigationController
+ (void)initialize{
if (@available(iOS 15.0, *)) {
UINavigationBarAppearance *appearance = [[UINavigationBarAppearance alloc] init];
appearance.backgroundImage = [UIImage imageWithColor:[UIColor whiteColor]]; //图片
appearance.backgroundColor = [UIColor whiteColor]; //背景色
appearance.shadowColor = [UIColor whiteColor]; //阴影
//等等其它属性,可以参考其他文章。
[UINavigationBar appearance].standardAppearance = appearance;
[UINavigationBar appearance].scrollEdgeAppearance = appearance;
}else{
//因为不是所有界面的barTintColor都一样,所以最好不要直接写
[[UINavigationBar appearance] setTintColor:UIColor.blackColor];
[UINavigationBar appearance].barTintColor = [UIColor whiteColor];
[UINavigationBar appearance].translucent = false;
[[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor colorWithHexString:@"#313331"]}];
}
//Xcode13 编译时 ,为了处理透明导航栏的Controller push 非透明导航栏时,导航出现白色背景异常的问题。
//原来设置导航栏的方式不能省略。
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageWithColor:[UIColor whiteColor]] forBarMetrics:UIBarMetricsDefault];
}
- (void)viewDidLoad {
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
if (self.viewControllers.count > 0) {
if (self.viewControllers.count == 1) {
viewController.hidesBottomBarWhenPushed = YES;
}
}else{
viewController.hidesBottomBarWhenPushed = NO;
}
[super pushViewController:viewController animated:animated];
}
网友评论