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.
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];
if let navigationBar = navigationController?.navigationBar {
navigationBar.setBackgroundImage(UIImage(), forBarMetrics: .Default)
navigationBar.shadowImage = UIImage()
navigationBar.translucent = true
navigationController?.view.backgroundColor = .clearColor()
}
if let navigationBar = navigationController?.navigationBar {
navigationBar.setBackgroundImage(UIImage(), for: .default)
navigationBar.shadowImage = UIImage()
navigationBar.isTranslucent = true
navigationController?.view?.backgroundColor = .clear
}
This works for sure! Transparent UINavigationBar.
这篇关于透明 UINavigationBar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!