How to hide the “back” button in UINavigationController?

前端 未结 14 2383
盖世英雄少女心
盖世英雄少女心 2020-12-04 07:09

Do you know how to hide the \'back\' button in a UINavigationController? Also, how to show it back, but I guess that\'s very similar to hiding it...

Just like the ma

14条回答
  •  萌比男神i
    2020-12-04 08:01

    Swift 3.

    Generally, you should use Apple's per-ViewController API as described many times already on this page, but sometimes you need immediate control of the Back button.

    The following code hides the Back button and ensures that tap collision detection doesn't occur in the hidden button region.

    let emptyView = UIView(frame: .zero)
    self.navigationItem.leftBarButtonItem = UIBarButtonItem(customView: emptyView)
    

提交回复
热议问题