[英]How to set tint color on pdf asset in Xcode?
I created a new image set, set "Scales" as "Single Scale" and placed my PDF asset in. Afterwards, I set "Render as" to "Template Image" and when I set a UIImageView to display my asset, it shows up but I cannot change the tint color in storyboard. 我创建了一个新的图像集,将“Scales”设置为“Single Scale”并将我的PDF资源放入其中。然后,我将“Render as”设置为“Template Image”,当我设置UIImageView来显示我的资产时,它会显示出来但我无法改变故事板中的色调。 Does anyone know what I need to do in order to be able to modify the tint color on a PDF vector asset in Xcode?
有没有人知道我需要做什么才能修改Xcode中PDF矢量资产的色调?
Setting the UIImageView's
image in code doesn't produce this problem. 在代码中设置
UIImageView's
图像不会产生此问题。
There is a bug in Xcode which prevents UIImageView
from coloring its template image in tint color when loaded from Interface Builder. Xcode中存在一个错误,当从Interface Builder加载时,它会阻止
UIImageView
其模板图像着色为彩色。 See: rdar://18448072 见: rdar:// 18448072
If you don't want to set the image in code, the most elegant solution I found was creating the following extension for UIImageView
: 如果你不想在代码中设置图像,我发现最优雅的解决方案是为
UIImageView
创建以下扩展:
import UIKit
extension UIImageView {
override public func awakeFromNib() {
super.awakeFromNib()
tintColorDidChange()
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.