Creating a transparent navigation bar
2 answers
Screenshot
Swift
self.navigationController?.navigationBar.setBackgroundImage(UIImage.new(), forBarMetrics: UIBarMetrics.Default)
self.navigationController?.navigationBar.shadowImage = UIImage.new()
OC
[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setShadowImage:[UIImage new]];
+3
source to share
I found a way:
Create a subclass UINavigationBar
and pass it to your navigation controller to use it.
class NavigationBar: UINavigationBar {
// An empty implementation will make the view to be transparent
override func drawRect(rect: CGRect) {
}
}
If you are using InterfaceBuilder, you can select a navigation controller, then select its navigation bar, and then change your class accordingly.
If you do it programmatically:
let navController = UINavigationController(navigationBarClass: NavigationBar.self, toolbarClass: nil)
...
Result with UIBarButtonItem:
Hope it helps
Old answer:
I tried for a long time (ios6). In principle, this is possible. Make the navigation bar color UIColor.clearColor()
. Buttons should be a regular UIView inside a UIBarButton to show how you want. I think you will also need to adjust the color of the view behind the navbar.
+1
source to share