可以将 CGImage 添加到 CAShapeLayer 的内容属性中吗?
我有一个带有 LayerClass 覆盖的自定义视图,如下所示:
+ (Class) layerClass
{
return [CAShapeLayer class];
}
我希望能够将 CGImage 添加到内容属性,如下所示:
- (void) animateView
{
UIImage *layerImage = ...;
CAShapeLayer *layer = (CAShapeLayer *)self.layer;
layer.contents = layerImage.CGImage;
//....Do other fun animations here
}
是否有其他我需要设置的属性,或其他方法来获取形状层以呈现内容的内容动画图像?
I have a custom view with a layerClass override like:
+ (Class) layerClass
{
return [CAShapeLayer class];
}
I want to be able to add a CGImage to the contents property like so:
- (void) animateView
{
UIImage *layerImage = ...;
CAShapeLayer *layer = (CAShapeLayer *)self.layer;
layer.contents = layerImage.CGImage;
//....Do other fun animations here
}
Are there other properties I need to set, or other ways to get the shape layer to render the contents of the image for animation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为不是:
CAShapeLayer
几乎只是用于渲染矢量路径。您是否尝试过创建通用图层,将图像指定为其内容,并将其添加为形状图层的子图层?I would assume not:
CAShapeLayer
is pretty much just used to render a vector path. Have you tried creating a generic layer, assigning your image as its contents, and adding it as a sublayer of your shape layer?