简体   繁体   English

改变 CALayer 的填充颜色

[英]Change Fill Color of CALayer

Is it possible to set the fill color of a CALayer that has already been drawn on screen?是否可以设置已在屏幕上绘制的 CALayer 的填充颜色?

I am using SVGKit to load a SVG image into a UIView and everything is working very well but I need to change the fill color.我正在使用 SVGKit 将 SVG 图像加载到 UIView 中,一切正常,但我需要更改填充颜色。 I have read up on CAShapeLayer.fillColor and think that it can be done easily but I don't seem to see an easy way to do it with a CALayer?我已经阅读了 CAShapeLayer.fillColor 并认为它可以很容易地完成,但我似乎没有看到使用 CALayer 来完成它的简单方法? I really do hope it can be done.我真的希望它能完成。

May be someone might even be able to suggest if a CALayer can be converted to a CAShapeLayer?也许有人甚至可以建议 CALayer 是否可以转换为 CAShapeLayer?

Look at the docs for CALayer and you'll see查看CALayer的文档,您会看到

@property CGColorRef backgroundColor

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

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