이상한 층 360도 회전하므로 I 코딩 :CATransaction는 I 무한 360도 회전 애니메이션을 수행 할
- (void)rotate
{
__weak typeof(self) weakSelf = self;
[CATransaction begin];
[CATransaction setDisableActions:NO];
[CATransaction setCompletionBlock:^{
[weakSelf rotate];
}];
[CATransaction setAnimationDuration:1.0];
[CATransaction setAnimationTimingFunction:
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
self.squareLayer.transform = CATransform3DRotate(self.squareLayer.transform, M_PI, 0, 0, 1);
[CATransaction commit];
}
M_PI 180 개도를 의미하고, 그래서 층 0
에서 M_PI * 1
, M_PI * 2
으로 회전 될 수 있다고 ...
하지만, 0
에서 M_PI
에 다음 M_PI
0
에를 회전축 선 것으로 밝혀졌습니다.
나는 그것은 CABasicAnimation
을 통해 만들 수 있습니다
CABasicAnimation *animatin = [CABasicAnimation animationWithKeyPath:@"transform"];
animatin.duration = 1.0;
animatin.fromValue = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(0, 0, 0, 1)];
animatin.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(M_PI, 0, 0, 1)];
animatin.repeatCount = HUGE_VALF;
animatin.fillMode = kCAFillModeForwards;
[self.squareLayer addAnimation:animatin forKey:@"a"];
코드는 위의 360도 완벽하게 레이어를 회전 할 수 있습니다.
하지만 첫 번째 구현에 대해 혼란 스럽습니다. 왜 그렇게 이상하게 회전합니까?
'rotate'의 구현은 무엇입니까? 자체적으로 반복해서 호출하는 첫 번째 구현입니까? –
예, 매번 현재 변환으로 M_PI가 회전되었습니다. – Bzmario