镜像翻转CGPath

发布于 2024-12-03 11:41:23 字数 102 浏览 1 评论 0原文

我有一个简单的圆形 CGPath。 我无法水平翻转它,就像镜面效果一样。

如果您正在回答这个问题,请尝试提供完整的代码,而不仅仅是一般参考......

谢谢

I have a simple circle CGPath.
I am having trouble flipping it horizontally, like a mirror effect.

If you are answering this question, please try to provide a full code and not only a general reference...

thx

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

七禾 2024-12-10 11:41:23
UIBezierPath* aPath = [UIBezierPath bezierPathWithOvalInRect:CGRectMake( 0, -240, 240, 240 )];

// This will mirror the path

CGAffineTransform rotation = CGAffineTransformMakeScale(1.0, -1.0);

CGMutablePathRef f = CGPathCreateMutable();
CGPathAddPath(f, &rotation, aPath.CGPath);

CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
pathAnimation.calculationMode = kCAAnimationPaced;
pathAnimation.fillMode = kCAFillModeRemoved;
pathAnimation.rotationMode = kCAAnimationRotateAutoReverse;
pathAnimation.removedOnCompletion = NO;
pathAnimation.path = f;
pathAnimation.repeatCount = HUGE_VALF;;
pathAnimation.duration  = 5.0f;
[r2.layer addAnimation:pathAnimation forKey:nil];
UIBezierPath* aPath = [UIBezierPath bezierPathWithOvalInRect:CGRectMake( 0, -240, 240, 240 )];

// This will mirror the path

CGAffineTransform rotation = CGAffineTransformMakeScale(1.0, -1.0);

CGMutablePathRef f = CGPathCreateMutable();
CGPathAddPath(f, &rotation, aPath.CGPath);

CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
pathAnimation.calculationMode = kCAAnimationPaced;
pathAnimation.fillMode = kCAFillModeRemoved;
pathAnimation.rotationMode = kCAAnimationRotateAutoReverse;
pathAnimation.removedOnCompletion = NO;
pathAnimation.path = f;
pathAnimation.repeatCount = HUGE_VALF;;
pathAnimation.duration  = 5.0f;
[r2.layer addAnimation:pathAnimation forKey:nil];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文