简体   繁体   English

图像资产目录颜色不变

[英]Image asset catalog color not changing

I added one image set and set its Render As -> Template Image.我添加了一组图像并将其渲染为 -> 模板图像。

Added one button to storyboard and changed its tint color.向情节提要添加了一个按钮并更改了其色调。 It works perfectly when I check in the simulator.当我检查模拟器时,它工作得很好。

Issue - 1) But color don't get updated in the storyboard.问题 - 1) 但颜色不会在故事板中更新。

I have added one image view and changed its tint color from the storyboard.我添加了一个图像视图并从故事板更改了它的色调。

Issue - 2) But color don't get updated in the storyboard nor the color change appears in the simulator.问题 - 2) 但颜色不会在情节提要中更新,模拟器中也不会出现颜色变化。

I have added one image view programmatically and set its image and tint color that works perfectly in the simulator.我以编程方式添加了一个图像视图,并设置了在模拟器中完美运行的图像和色调颜色。

What might be the above issues any idea?有什么想法可能是上述问题?

Issue 1) That seems issue with Xcode, next releases may come up with fix.问题 1) 这似乎是 Xcode 的问题,下一个版本可能会修复。

Issue 2) That seems issue with Xcode too.. When I faced that situation I had to add ImageView programmatically which worked.问题 2)这似乎也是 Xcode 的问题.. 当我遇到这种情况时,我不得不以编程方式添加 ImageView,它起作用了。 You may also try IBDesignable or Custom class or Extension which changes renderMode property.您还可以尝试更改 renderMode 属性的 IBDesignable 或自定义类或扩展。

Issue - 1) But color don't get updated in the storyboard.问题 - 1) 但颜色不会在故事板中更新。
have look this one : ios 7.1 UITextField tint color doesn't change in storyboard看看这个: ios 7.1 UITextField 色调颜色在故事板中没有改变

Issue - 2) But color don't get updated in the storyboard nor the color change appears in the simulator.问题 - 2) 但颜色不会在情节提要中更新,模拟器中也不会出现颜色变化。

this issue arise for the template rendering mode with a UIImageView in a storyboard or xib, on iOS 7 , iOS 8 , iOS9 and iOS10 cause it is still buggy.这个问题出现在故事​​板或 xib 中带有 UIImageView 的模板渲染模式,在 iOS 7 、iOS 8 、iOS9 和 iOS10 上,因为它仍然有问题。

more information check this thread Modify UIImage renderingMode from storyboard/xib file更多信息检查这个线程Modify UIImage renderingMode from storyboard/xib file

I think so programmatically is good solution.我认为以编程方式是很好的解决方案。

Was it suppose to reflect Template Image color on StoryBoard by changing Tint ?是否应该通过更改Tint来反映 StoryBoard 上的模板图像颜色?

I checked on Xcode 8.2.1 , Xcode 8.1 , Xcode 8.0 and Xcode 7.3.1我检查了Xcode 8.2.1Xcode 8.1Xcode 8.0Xcode 7.3.1

None of them reflected the color on StoryBoard.它们都没有反映 StoryBoard 上的颜色。 Its works fine on Simulator and iPhone though.不过,它在模拟器和 iPhone 上运行良好。

I don't think this functionality was ever there.我不认为这个功能曾经存在过。 Correct me if I'm wrong.如果我错了纠正我。

The only way I've been able to get it to work is by creating an outlet of the UIImageView and calling this in viewDidLoad (or in VC):我能够让它工作的唯一方法是创建 UIImageView 的出口并在 viewDidLoad (或在 VC 中)调用它:

imageView.tintColorDidChange()

This has been a bug since iOS 7 or 8 I believe.我相信这是自 iOS 7 或 8 以来的错误。

我认为这个问题在 Xcode 11 中得到了解决。我在 iOS 13、12 和 11 上进行了测试,现在它在故事板、模拟器和设备中运行良好在故事板和 Xib 中。

Try尝试

Clear the derived data清除派生数据

Clean Project清洁工程

or要么

Use custom button使用自定义按钮

请获取该图像视图的 iboutlet 并以编程方式更改色调颜色。

Try refreshing all views, maybe it helps:尝试刷新所有视图,也许有帮助:

截屏

Simply, from Xcode, go to assets > then select your image > then from Inspectors menu (on the right): change the value of Render as to Template image简单地,从 Xcode,转到资产> 然后选择您的图像 > 然后从检查器菜单(在右侧):将渲染为的值更改模板图像

在此处输入图片说明

Then go to your storyboard > then change Tint color as you wish, and voila!然后转到您的故事板 > 然后根据需要更改色调颜色,瞧!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM