Adding back button to navigation bar

后端 未结 3 1208
终归单人心
终归单人心 2020-12-03 09:02

I\'ve added a navigation bar to a UIViewController. It is displayed from another UIViewController only. I\'d like to have a left side back button that is shaped similar to

3条回答
  •  伪装坚强ぢ
    2020-12-03 09:22

    Another approach to solve this problem is to set the items property for the navigation bar instead of consecutively pushing the bar items into nav bar stack:

    //Define myFrame based on your needs
    let navigationBar = UINavigationBar(frame: myFrame)
    let backItem = UINavigationItem(title: "Back")
    let topItem = UINavigationItem(title: "My Title")
    navigationBar.setItems([backItem,topItem], animated: false)
    

提交回复
热议问题