[英]Statusbar become transparent
I need to remove the UINavigationBar
shadow image. 我需要删除
UINavigationBar
阴影图像。
so I'm using the code below: 所以我使用下面的代码:
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
self.navigationController?.navigationBar.shadowImage = UIImage()
It is working perfectly, but the area behind the status bar became transparent, like the image below: 它工作正常,但是状态栏后面的区域变为透明的,如下图所示:
and I don't need this. 我不需要这个 It should be white.
应该是白色的。 What should I do?
我该怎么办? Any help will be appreciated.
任何帮助将不胜感激。
Thanks in Advance. 提前致谢。
This occurs beause the navigation bar does not have a specified bar tint color. 这是因为导航栏没有指定的栏色调颜色。 If you want to have a navigation bar with a bar tint color, you can set it in the IB inspector or programmatically:
如果您希望导航条带有条形颜色,则可以在IB检查器中或通过编程设置它:
navigationController?.navigationBar.barTintColor = .white
Well I found the the answer: 好吧,我找到了答案:
It was just online statement, ie: 这只是在线声明,即:
navigationController?.navigationBar.isTranslucent = false
By adding this in viewDidLoad
it started working as I wanted. 通过在
viewDidLoad
添加它,它开始按我的viewDidLoad
工作。 I got helped from this post https://stackoverflow.com/questions/38796259/remove-shadow-line-below-navigation-bar-without-removing-bar-color
我从这篇文章中获得了帮助
https://stackoverflow.com/questions/38796259/remove-shadow-line-below-navigation-bar-without-removing-bar-color
You have to hide the status bar to remove it. 您必须隐藏状态栏才能将其删除。
1. Open Info.plist file
2. Click + button to add new key
3. "UIViewControllerBasedStatusBarAppearance" set to NO
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.