Reputation: 73
I have made a CAShapeLayer
with few points by setting its stroke color to red . Then i have filled the color with a pattern of an UIImage
. I want to rotate that CAShapeLayer
along with its filled pattern using UIRotationGestureRecognizer
.
I have used CATransform3DRotate but it is not working properly.
CATransform3D transform = CATransform3DIdentity;
transform = CATransform3DRotate(transform, recognizer.rotation, 0.0, 0.0, 1.0);
shapeLayer.transform = transform;
Thanks in advance
Upvotes: 3
Views: 9139
Reputation: 9543
You'll want to call:
shapeLayer.anchorPoint = (CGPoint){0.5, 0.5};
You're also starting with the identity transform, which throws away any transformations you've done before, like positioning the layer. What you want to do is:
shapeLayer.transform = CATransform3DRotate(shapeLayer.transform, recognizer.rotation, 0.0, 0.0, 1.0);
Upvotes: 9