Custom UINavigationBar background image appears darker than the original image

左心房为你撑大大i 提交于 2019-12-20 06:26:48

问题


I am customizing a UINavigationBar like so:

UIImage * img = [UIImage imageNamed:@"background.png"];
[[UINavigationBar appearance] setBackgroundImage:img forBarMetrics:UIBarMetricsDefault];

My original image background.png looks like this:

It has a flat color #4b0367

The resulting NavigationBar looks like this:

It has the color #311253 which is different from the original! Apparently UIKit changes the color.

Note:

  • Setting tintColor had no effect.
  • Setting a transparent background image + a color is not an appropriate solution in my case.

Does anybody know how the underlying mechanism works? How can I get the original image to appear correctly?

来源:https://stackoverflow.com/questions/16190127/custom-uinavigationbar-background-image-appears-darker-than-the-original-image

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