如何在其中心点旋转CAShapeLayer

Hit*_*waj 3 iphone objective-c calayer cashapelayer ios

CAShapeLayer通过将其笔触颜色设置为红色,我创建了几个点.然后我用一种模式填充了颜色UIImage.我想CAShapeLayer用它的填充图案旋转它UIRotationGestureRecognizer.

我使用过CATransform3DRotate,但它无法正常工作.

CATransform3D transform = CATransform3DIdentity;
transform = CATransform3DRotate(transform, recognizer.rotation, 0.0, 0.0, 1.0);
shapeLayer.transform = transform;
Run Code Online (Sandbox Code Playgroud)

提前致谢

Wil*_*ley 8

你想打电话:

shapeLayer.anchorPoint = (CGPoint){0.5, 0.5};
Run Code Online (Sandbox Code Playgroud)

你也开始使用身份变换,这会抛弃你以前做过的任何变换,比如定位图层.你想要做的是:

shapeLayer.transform = CATransform3DRotate(shapeLayer.transform, recognizer.rotation, 0.0, 0.0, 1.0);
Run Code Online (Sandbox Code Playgroud)

  • @HiteshBhardwaj在那种情况下,我猜测形状图层没有设置边界 (8认同)