如何在Swift 4的导航栏上添加图像后退按钮

时间:2019-07-08 09:41:13

标签: ios swift swift4

如何将图像作为后退按钮添加到导航栏的左侧。我需要在导航栏中向左箭头。我需要快速解决方案4。

3 个答案:

答案 0 :(得分:0)

您可以执行以下操作:

let yourBackImage = UIImage(named: "back_button_image")
self.navigationController?.navigationBar.backIndicatorImage = yourBackImage
self.navigationController?.navigationBar.backIndicatorTransitionMaskImage = yourBackImage
self.navigationController?.navigationBar.backItem?.title = "Custom"

答案 1 :(得分:0)

let backButtonItem = UIBarButtonItem(image: UIImage(named: "left_arrow_icon"), style: .done, target: self, action: #selector(didTapOnBack))   
self.navigationItem.leftBarButtonItem = backButtonItem

答案 2 :(得分:0)

将“栏按钮项”拖到导​​航栏中,然后将所需的图像设置为该按钮。enter image description here