iOS 导航栏返回把样式带回前面怎么办

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//设置当前页面导航栏
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
     
    // 让导航栏背景透明
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    self.navigationController.navigationBar.translucent = YES;
    self.navigationController.navigationBar.barTintColor = [UIColor clearColor];
    self.navigationController.navigationBar.shadowImage = [UIImage new];
    [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
 
    if (@available(iOS 13.0, *)) {
            UINavigationBarAppearance *appearance = [UINavigationBarAppearance new];
            [appearance configureWithOpaqueBackground];
            // 改变导航栏的颜色
            appearance.backgroundColor = [UIColor clearColor];
            // 改变导航栏的标题颜色,这里改没什么用的,要去继承的父类那里去改就是 YHNavigationController.m那里
            appearance.titleTextAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:18],
                                              NSForegroundColorAttributeName:[UIColor whiteColor]};
            //导航栏包含状态栏 阴影线颜色背景色设置
            appearance.shadowColor = [UIColor clearColor];
            self.navigationController.navigationBar.standardAppearance = appearance;
            self.navigationController.navigationBar.scrollEdgeAppearance = self.navigationController.navigationBar.standardAppearance;
    }
//    self.navigationItem.rightBarButtonItem.tintColor = [UIColor blackColor];//右边的按钮颜色
    self.navigationItem.leftBarButtonItem.tintColor = [UIColor blackColor];
    self.navigationItem.backBarButtonItem.tintColor = [UIColor blackColor];
}
//返回时恢复到前面的导航栏
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
     
    // 导航栏恢复不透明显示
    UIColor *topColor = [EBSkinLib shareInstance].globalColor_3;
     
    UIColor *bottomColor = [EBSkinLib shareInstance].globalColor;
     
    UIImage *bgImg = [UIImage gradientColorImageFromColors:@[topColor, bottomColor] gradientType:GradientTypeTopToBottom imgSize:CGSizeMake(self.view.frame.size.width, navBarHeight)];
     
    self.navigationController.navigationBar.translucent = NO;
    [self.navigationController.navigationBar setBackgroundImage:bgImg forBarMetrics:UIBarMetricsDefault];
//    self.navigationController.navigationBar.barTintColor = barTineColor;
     
}

 

posted on   高彰  阅读(49)  评论(0编辑  收藏  举报

< 2025年1月 >
29 30 31 1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31 1
2 3 4 5 6 7 8

导航

统计

点击右上角即可分享
微信分享提示