UIBarButtonItem是蓝色而不是图像 [英] UIBarButtonItem is blue instead of image

查看:146
本文介绍了UIBarButtonItem是蓝色而不是图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的viewDidLoad方法中的内容:

Here is what I have in my viewDidLoad method:

self.navigationController?.navigationBar.backIndicatorImage = UIImage(named: "back")
self.navigationController?.navigationBar.backIndicatorTransitionMaskImage = UIImage(named: "back")
self.navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: UIBarButtonItemStyle.Plain, target: nil, action: nil)

我正在尝试在导航控制器中为我的后退按钮提供自定义图标图像.我看到的是蓝色,而不是原始格式的图像. 如何使图像正确显示?

I am trying to have a custom icon image for my back button in my navigation controller. Instead of the image showing in it's original format, I am seeing the image in blue. How do I get the image to show properly?

推荐答案

您可以在AlwaysOriginal模式下将renderingMode用于自定义图像.请参见下面的代码以解决它.

You can use renderingMode for your custom image with AlwaysOriginal mode. See below code for solved it.

self.navigationController?.navigationBar.backIndicatorImage = UIImage(named: "back")?.imageWithRenderingMode(.AlwaysOriginal)
self.navigationController?.navigationBar.backIndicatorTransitionMaskImage = UIImage(named: "back")?.imageWithRenderingMode(.AlwaysOriginal)

希望有帮助!

这篇关于UIBarButtonItem是蓝色而不是图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆