镜像翻转CGPath

时间:2011-09-09 09:04:50

标签: ios core-graphics cgcontext cgpath uibezierpath

我有一个简单的圆圈CGPath。 我无法横向翻转它,就像镜面效果一样。

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

THX

1 个答案:

答案 0 :(得分:4)

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];