zoukankan      html  css  js  c++  java
  • iOS 导航栏返回把样式带回前面怎么办

    //设置当前页面导航栏
    - (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;
        
    }
    
  • 相关阅读:
    springboot设置banner
    pytorch(分布式)数据并行个人实践总结——DataParallel/DistributedDataParallel
    jupyter之配置自己喜欢的python环境
    ImportError: DLL load failed: 找不到指定的模块;ImportError: numpy.core.multiarray failed to import 报错解决
    multitask learning 相关论文资源
    python如何删除二维或者三维数组/列表中某维的空元素
    finished with exit code -1073740791 (0xC0000409)解决方案
    Keras学习系列——神经网络层组件
    腾讯云搭建个人博客wordpress
    多任务学习相关资料整理
  • 原文地址:https://www.cnblogs.com/gaozhang12345/p/15787488.html
Copyright © 2011-2022 走看看