는이 같은 레이어의 transform.rotation
키 경로를 애니메이션하여 Z 축을 중심으로 하나 (또는 그 이상)의 전체 회전을 통해 레이어에 애니메이션을 적용 할 수 있습니다 :
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
animation.duration = .25;
animation.fromValue = [NSNumber numberWithFloat:0];
animation.toValue = [NSNumber numberWithFloat:2 * M_PI];
[layer addAnimation:animation forKey:animation.keyPath];
당신은 X 또는 Y 축을 중심으로 애니메이션을 적용 할 수 있습니다 키 경로 transform.rotation.x
및 transform.rotation.y
을 사용하십시오. transform.rotation.z
키 경로는 transform.rotation
키 경로와 동일한 효과를냅니다. 여러 회전을 별도의 축에 동시에 적용 할 수 있습니다.
CALayer *layer = [sender layer];
CATransform3D transform = CATransform3DIdentity;
transform.m34 = 1.0/-50;
layer.transform = transform;
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
animation.values = [NSArray arrayWithObjects:
[NSValue valueWithCATransform3D:CATransform3DRotate(transform, 0 * M_PI/2, 100, 1, 100)],
[NSValue valueWithCATransform3D:CATransform3DRotate(transform, 1 * M_PI/2, 100, 1, 100)],
[NSValue valueWithCATransform3D:CATransform3DRotate(transform, 2 * M_PI/2, 100, 1, 100)],
[NSValue valueWithCATransform3D:CATransform3DRotate(transform, 3 * M_PI/2, 100, 1, 100)],
[NSValue valueWithCATransform3D:CATransform3DRotate(transform, 4 * M_PI/2, 100, 1, 100)],
nil];
animation.duration = 2;
[layer addAnimation:animation forKey:animation.keyPath];
당신은 180 또는 360도 회전하려고 :
당신이 떨어져 축 벡터 주위를 회전 할 경우 아마 잘 작동을 할 수있는 또 다른 방법은, 다음과 같이, 키 프레임 애니메이션을 사용하고 ? 360도 회전은 전혀 회전하지 않는 것과 같습니다. – htinlinn
@htinlinn 전 360도 회전을 통해 자신의 레이어에 애니메이션을 적용하려고합니다. –
@robmayoff 아. 승인. – htinlinn