简体   繁体   中英

Changing the identifier of a UIBarButton Item to an image in swift

In an iOS app I am making, I have set the identifier of a bar button item programmatically using:

homeTitleBar.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .Trash, target: self, action: nil)

Which changes the button to a trash can.

My question is, after that, how can I then change it to a custom image.

homeTitleBar.leftBarButtonItem?.image = UIImage(named: "settingsIcon")

does not seem to be working.

尝试

homeTitleBar.leftBarButtonItem = UIBarButtonItem(image:UIImage(named: "settingsIcon"), style: UIBarButtonItemStyle.Plain, target: self, action: nil)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM