Search code examples
iosswiftuinavigationcontrolleruinavigationbar

Create a Transparent NavigationBar


I am wondering how do we create a UINavigationBar that is totally transparent (alpha = 0) but the BarButton Item is still visible.

I would like to have an Invisible NavigationBar but I need the BarButtonItem to be visible.


Solution

  • 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]];