简体   繁体   中英

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

在此处输入图片说明

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.

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))

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