Setting a Custom Image for a Back Button on UINavigationBar

前端 未结 8 2176
伪装坚强ぢ
伪装坚强ぢ 2020-12-14 10:55

I am trying to set a custom image for the back button that automatically gets place onto a navigation bar when a new view is pushed onto the stack.

I have tried add

8条回答
  •  一整个雨季
    2020-12-14 11:16

    This worked for me:

    let button1 = UIBarButtonItem(
        image: #imageLiteral(resourceName: "back_arrow"), 
        style: .plain, 
        target: self, 
        action: #selector(self.backBtnTapped(_:))
    )
    self.navigationItem.leftBarButtonItem  = button1
    

提交回复
热议问题