leftbarbuttonitem does not show up in the navigation bar

前端 未结 7 1788
Happy的楠姐
Happy的楠姐 2021-01-17 10:07

I\'ve been developing an iOS app and have been having issues with using an image as the left bar button item in the navigation bar. I have attempted this in the following wa

7条回答
  •  情歌与酒
    2021-01-17 10:46

    Updated for Swift 5:

    let image = UIImage(named: "iconClose")
    let button = UIBarButtonItem(image: image, style: .plain, target: self, action: #selector(self.cancel))
    navigationItem.leftBarButtonItem = button
    

提交回复
热议问题