将navigationBar背景图片设置为[UIImage new]后恢复

Restore navigationBar background image after setting it to [UIImage new](将navigationBar背景图片设置为[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]后恢复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Why local notification is not firing for UNCalendarNotificationTrigger(为什么没有为UNCalendarNotificationTrigger触发本地通知)
iOS VoiceOver functionality changes with Bundle Identifier(IOS画外音功能随捆绑包标识符而变化)
tabbar middle tab out of tabbar corner(选项卡栏中间的选项卡角外)
Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Get an event when UIBarButtonItem menu is displayed(显示UIBarButtonItem菜单时获取事件)