我需要一个完全透明的 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]后恢复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!