gpt4 book ai didi

ios - 如何在中心点旋转 CAShapeLayer

转载 作者:可可西里 更新时间:2023-11-01 17:07:46 24 4
gpt4 key购买 nike

我通过将描边颜色设置为红色制作了一个带有几个点的CAShapeLayer。然后我用 UIImage 的图案填充颜色。我想使用 UIRotationGestureRecognizer 旋转 CAShapeLayer 及其填充图案。

我使用了 CATransform3DRotate,但它无法正常工作。

CATransform3D transform = CATransform3DIdentity;
transform = CATransform3DRotate(transform, recognizer.rotation, 0.0, 0.0, 1.0);
shapeLayer.transform = transform;

提前致谢

最佳答案

您需要调用:

shapeLayer.anchorPoint = (CGPoint){0.5, 0.5};

您还从恒等变换开始,它会丢弃您之前完成的任何变换,例如定位图层。你想要做的是:

shapeLayer.transform = CATransform3DRotate(shapeLayer.transform, recognizer.rotation, 0.0, 0.0, 1.0);

关于ios - 如何在中心点旋转 CAShapeLayer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20996065/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com