透明的UINavigationBar [英] Transparent UINavigationBar
本文介绍了透明的UINavigationBar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是ios的新手,我找到了使UINavigationBar透明的解决方案. 可以在我的项目文件中的哪个位置放置此代码
Am newbie to ios and I found this solution on making the UINavigationBar Transparent. Where in my project files can I put this code
[self.navigationBar setBackgroundImage:[UIImage new]
forBarMetrics:UIBarMetricsDefault];
self.navigationBar.shadowImage = [UIImage new];
self.navigationBar.translucent = YES;
以便将其应用于正在使用导航控制器的整个项目中.
So that it is applied in my entire project where navigation controller is being used.
推荐答案
在您的rootViewController的viewDidLoad
函数中输入以下代码:
Put in your viewDidLoad
function of your rootViewController this code:
[self.navigationController.navigationBar setBackgroundImage:[UIImage new]
forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.shadowImage = [UIImage new];
self.navigationController.navigationBar.translucent = YES;
self.navigationController.view.backgroundColor = [UIColor clearColor];
Swift 2.x:
if let navigationBar = navigationController?.navigationBar {
navigationBar.setBackgroundImage(UIImage(), forBarMetrics: .Default)
navigationBar.shadowImage = UIImage()
navigationBar.translucent = true
navigationController?.view.backgroundColor = .clearColor()
}
迅速3:
if let navigationBar = navigationController?.navigationBar {
navigationBar.setBackgroundImage(UIImage(), for: .default)
navigationBar.shadowImage = UIImage()
navigationBar.isTranslucent = true
navigationController?.view?.backgroundColor = .clear
}
这可以肯定! 透明UINavigationBar .
这篇关于透明的UINavigationBar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文