1
UIBezierPath를 따라 애니메이션을 적용하는 방법에 대한 예제가 많이 있습니다. 하지만 UIBezierPath의 appendPath 만 애니메이션으로 만드는 방법을 알 수는 없습니다. 내 경우iOS - UIBezierPath의 'appendPath'만 애니메이션화하십시오.
난 다음 예제를 가지고 :
// Create path from view controller
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:
CGRectMake(0, 0, tutorialController.bounds.size.width,
tutorialController.bounds.size.height) cornerRadius:0];
// Create circle path
UIBezierPath *circlePath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(x, y, 2.0*radius, 2.0*radius) cornerRadius:radius];
[path appendPath:circlePath];
[path setUsesEvenOddFillRule:YES];
// Create spot layer
spotLayer = [CAShapeLayer layer];
spotLayer.path = path.CGPath;
spotLayer.fillRule = kCAFillRuleEvenOdd;
spotLayer.fillColor = [UIColor blackColor].CGColor;
spotLayer.opacity = 0.90;
그래서 기본적으로 자사의 구형 영역의 내부 원과 나는 이제 원을 애니메이션을 적용 할. 모든 시도에서 rect도 움직였다. 여기
은 (내가 경로
CGPoint pathStart = CGPointMake(96.000000, 226.000000);
CGPoint pathEnd = CGPointMake(120.000000, 300.000000);
[circlePath moveToPoint:pathStart];
[circlePath addLineToPoint:pathEnd];
CAKeyframeAnimation *anim = [CAKeyframeAnimation animationWithKeyPath:@"position"];
anim.path = circlePath.CGPath;
anim.duration = 5.0;
anim.calculationMode = kCAAnimationPaced;
[spotLayer addAnimation:anim forKey:@"bezierPathAnim"];
"함께"애니메이션 할 수 있습니다하지만 난 내 원 경로를 이동, 내가 뭘하고 싶은 것입니다 ... 원하는 것이 아니다 방법, 내 예이다 애니메이션을 통해 사각형 경로의 추가 경로)
누구에게 아이디어가 있습니까?
안부
정확히 코드의 "애니메이션"부분은 무엇입니까? – matt
현재 나에게 맞는 것은 없습니다. 따라서 CAKeyframeAnimation을 사용하여 경로를 따라 애니메이션을 만들 수 있습니다. –
왜 직사각형 패스를 포함하고 다른 하나는 원 경로를 포함하는 두 개의 모양 레이어를 만들고 그 중 하나만 애니메이션으로 만듭니다. – matt