Search code examples
iosuinavigationcontrolleruinavigationbaruibarbuttonitemuinavigationitem

iOS - What is the proper way to just display back button and no navigationBar?


enter image description here

Above design can be achieve using setNavigationBarHidden = YES and by adding UIButton at the top for backButton behavior. But I wanna avoid this hack/method.

Is it possible I can still use leftBarButtonItems for backButton without navigationBar ?

What is the recommended and proper approach for this kind of design ?


Solution

  • leftBarButtonItems is an accessory which is only used with navigation bar, if you want to use that you will only use it with navigation bar.

    Now if you dont want to add the custom button, then just make the UINavigationBar transparent using the below code.

    [self.navigationBar setBackgroundImage:[UIImage new]
                             forBarMetrics:UIBarMetricsDefault];
    self.navigationBar.shadowImage = [UIImage new];
    self.navigationBar.translucent = YES;