ios - Bar button item image (UIImage) color changes with tint color?
问题描述
I am trying to set an image for bar button item based on a condition. I need to show 2 different images. The tint color property is affecting the color of my image itself. How to change this? When i give “clear color” as tint color the image is not getting displayed at all.
解决方案
用这个
斯威夫特 2.x
var image = UIImage(named:"myImage").imageWithRenderingMode(.AlwaysOriginal)
斯威夫特 3.x 或 4
var image = UIImage(named:"myImage")?.withRenderingMode(.alwaysOriginal)
并将其设置为您的 UIBarButtonItem
推荐阅读
- javascript - Javascript - 是否可以使用具有特定属性路径的 fetch 或 axios.get?
- r - 在 RI 中使用 switch 函数希望根据空行给出条件结果
- rest - 通过 REST 调用自定义 DevOps 通知订阅
- python - 将 numpy.array 传递给函数但值未更改
- python - 查找前一行的值是否为最大值
- powerbi - Dax 函数将销售目标转换为每日目标
- microsoft-teams - 从消息扩展返回 AdaptiveCard 的正确方法是什么?
- c# - 如何重置 JsonReader 实例而不是调用 JToken.CreateReader?
- oracle - oracle forms 12c 我可以在没有客户端安装的情况下在互联网上获取应用程序吗
- apache-camel - 如何使用 Camel 向 Azure SQL DB 消费和生成消息