我有一个 CAShapeLayer,我可以使用 UIRotationGestureRecognizer 旋转它。但是在旋转时,它只旋转它的框架而不是它里面的填充图案。
CAShapeLayer *shapeLayer = [finalShapeLayersArray objectAtIndex:indextobeRotated];
CGPathRef path = createPathRotatedAroundBoundingBoxCenter(shapeLayer.path,recognizer.rotation);
shapeLayer.path = path;
CGPathRelease(path);
recognizer.rotation = 0;
Bu 这样做,它只会旋转 CAShapeLayer 的边界。我用图像填充了一个图案。我只是希望该模式也应该旋转。
最佳答案
您需要使用 CALayer's transform
property 在图层上设置一个旋转变换相反(您不旋转形状路径,因为整个图层都将旋转)。
参见 this answer关于如何创建这样的转换。另见 Core Animation Function Reference对于可以创建/修改转换的所有函数。
关于ios - 如何旋转 CAShapeLayer 及其图案?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20856811/