JLT
JLT

Reputation: 3172

iOS - How to remove highlighting of selected items in Tab Bar

I am customizing the tab bar, and I don't my items to be highlighted with the tint color set to the tab bar item. I wan't the highlight to be just the image that I set for the selectedImage property of the tab bar item.

This is what it looks like now

enter image description here

I don't want my image to be highlighted with blue. I want it to be just the image that I set.

Please don't tell me about changing tint colors. I am not asking about tint colors here.

Upvotes: 0

Views: 1559

Answers (1)

mag_zbc
mag_zbc

Reputation: 6992

As per UITabBarItem documentation for init(title:image:selectedImage:) initializer:

By default, the actual unselected and selected images are automatically created from the alpha values in the source images. To prevent system coloring, provide images with alwaysOriginal

So, in your case:

let yourTabBarItem = UITabBarItem(title: yourTitle, image: yourImage.withRenderingMode(.alwaysOriginal), selectedImage: yourSelectedImage.withRenderingMode(.alwaysOriginal))

Upvotes: 4

Related Questions