사각형의 UIBezierPath를 삼각형 모양으로 애니메이션하고 싶습니다. 경로의 뷰에 애니메이션을 적용하는 것이 아니라 경로 자체를 애니메이션화하여 한 도형에서 다른 도형으로 변형합니다. 경로는 내가 코어 애니메이션에 대한 전문가 모르지만UIBezierPath 애니메이션하는 방법
CABasicAnimation *morph = [CABasicAnimation animationWithKeyPath:@"path"];
morph.duration = 5;
morph.toValue = (id) [self getTrianglePath];
[maskLayer addAnimation:morph forKey:nil];
첫 번째 줄을 다음과 같이 당신이 CABasicAnimation
을 정의 할 수있는 CALayer
CAShapeLayer *maskLayer = [CAShapeLayer layer];
maskLayer.fillColor = [[UIColor whiteColor] CGColor];
maskLayer.path = [self getRectPath];
-(CGPathRef)getTrianglePath
{
UIBezierPath* triangle = [UIBezierPath bezierPath];
[triangle moveToPoint:CGPointZero];
[triangle addLineToPoint:CGPointMake(width(self.view),0)];
[triangle addLineToPoint:CGPointMake(0, height(self.view))];
[triangle closePath];
return [triangle CGPath];
}
-(CGPathRef)getRectPath
{
UIBezierPath*rect = [UIBezierPath bezierPathWithRect:self.view.frame];
return [rect CGPath];
}
감사합니다. 나는 CAKeyframeAnimation을 사용하고 있었다. –