Restore navigationBar background image after setting it to [UIImage new](将navigationBar背景图片设置为[UIImage new]后恢复)
问题描述
我需要一个完全透明的 mapView 导航栏,所以我这样做了:
I needed a completely transparent navigation bar for the mapView so I did this:
[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setShadowImage:[UIImage new]];
返回所需的效果,如下所示:
That returns the desired effect, as seen here:
现在我去任何其他地方时都会遇到问题,因为我的导航栏保持透明:
Now I have a problem when I go to any other because my navigationBar remains transparent:
如何恢复navigationBar的backgroundImage和shadowImage的默认设置?
How do I restore default settings of the navigationBar's backgroundImage and shadowImage?
推荐答案
在地图视图的 viewWillDisappear
上为导航控制器的图像设置 nil
Set nil for image of navigation Controller on viewWillDisappear
on map view
在你的地图视图中设置这两种方法
Set this two method in your mapview
地图视图.m
-(void)viewWillAppear:(BOOL)animated{
[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setShadowImage:[UIImage new]];
}
-(void)viewWillDisappear:(BOOL)animated{
[self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setShadowImage:nil];
}
这篇关于将navigationBar背景图片设置为[UIImage new]后恢复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:将navigationBar背景图片设置为[UIImage new]后恢复


- GPS状态的广播接收器? 2022-01-01
- 在 Iphone SDK 的导航栏上添加多个按钮 2022-01-01
- URL编码Swift iOS 2022-01-01
- 网上有没有好的 UIScrollView 教程? 2022-01-01
- 使用自动布局向 UIScrollView 添加动态大小的视图 2022-01-01
- SetOnItemSelectedListener上的微调程序错误 2022-01-01
- Xcode 7.3 中带有 UILabel 的 UIStackView 2022-01-01
- UITextView 内容插图 2022-01-01
- 如何在 iPhone 模拟器中重置 NSUserDefaults 数据? 2022-01-01
- 类似于 Mail.app 的 iPad 模态视图控制器? 2022-01-01