disable tint on custom uibarbuttonitem images

烈酒焚心 提交于 2020-01-11 05:02:10

问题


i have some custom bar button items in my navigation controller.

(maximize the image to see the borders better)

the above screenshot is how it should look like and how i added the barbutton item image. as you can see, the icon has some darker gradients on top.

but since all icons get tinted, this dark gradient gets also tinted white and my icon looks extremely blurry.

i just dropped them into my storyboard.

is there a way to disable tinting this barbuttonitems?


回答1:


In iOS 7, a navigation bar’s tintColor affects the color of the back indicator image, button titles, and button images. The barTintColor property affects the color of the bar itself. So, you can try setting the barTintColor and check if it solves your issue.

Also, when using the barButtonItem images, the following code is worth a try:

myImage = [myImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];



回答2:


Adding to Anindya Answer:

In Xcode 9.2,

You can change the "Render As" property to "Original" in Attribute Inspector of Assets. This will prevent NavigationBar.TintColor to take effect on that Image if you used it in UIBarButtonItem



来源:https://stackoverflow.com/questions/22482821/disable-tint-on-custom-uibarbuttonitem-images

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!