【问题标题】:How to rotate a CAShapeLayer along with its Pattern?如何旋转 CAShapeLayer 及其图案?
【发布时间】:2013-12-31 11:41:26
【问题描述】:

我有一个 CAShapeLayer,我可以使用 UIRotationGestureRecognizer 旋转它。但是在旋转时,它只旋转它的框架而不是它里面的填充图案。

        CAShapeLayer *shapeLayer = [finalShapeLayersArray objectAtIndex:indextobeRotated];
        CGPathRef path = createPathRotatedAroundBoundingBoxCenter(shapeLayer.path,recognizer.rotation);
        shapeLayer.path  = path;
        CGPathRelease(path);
        recognizer.rotation = 0;

这样做,它只会旋转 CAShapeLayer 的边界。我已经用图像填充了一个图案。我只是希望该模式也应该旋转。

【问题讨论】:

  • 这些信息不足以回答您的问题。您需要编辑您的问题并更新您的设置的更详细描述,最好使用演示问题的代码。

标签: ios objective-c transform calayer


【解决方案1】:

您需要使用CALayer's transform property 在您的图层上设置旋转变换(您不要旋转形状路径,因为整个图层将被旋转)。

请参阅this answer,了解如何创建这样的转换。另请参阅Core Animation Function Reference,了解所有可以创建/修改转换的函数。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多