开发者

Can a CGImage be added to the contents property of a CAShapeLayer?

开发者 https://www.devze.com 2023-01-05 18:37 出处:网络
I have a custom view with a layerClass override like: + (Class) layerClass { return [CAShapeLayer class];

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 *layerI开发者_如何学Cmage = ...;
    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?


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?

0

精彩评论

暂无评论...
验证码 换一张
取 消