简体   繁体   中英

Bar button item image (UIImage) color changes with tint color?

I am trying to set an image for bar button item based on a condition. I need to show 2 different images. The tint color property is affecting the color of my image itself. How to change this? When i give “clear color” as tint color the image is not getting displayed at all.

Use this

Swift 2.x

var image = UIImage(named:"myImage").imageWithRenderingMode(.AlwaysOriginal)

Swift 3.x or 4

var image = UIImage(named:"myImage")?.withRenderingMode(.alwaysOriginal)

And set it to your UIBarButtonItem

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