我一直在尝试制作一个圆形 CALayer 以简单地在其中心旋转。我只能让它在错误的 anchor 上旋转。我试图改变这个 anchor ,但动画保持不变。
- (void)rotateImage {
CABasicAnimation* rotationAnimation;
rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.fromValue = [NSNumber numberWithFloat:0];
rotationAnimation.toValue = [NSNumber numberWithFloat: -M_PI*2];
rotationAnimation.duration = 1;
rotationAnimation.repeatCount = INFINITY;
[self.surroundingCircles addAnimation:rotationAnimation forKey:@"rotationAnimation"];
}
结果:https://www.dropbox.com/s/gmlxw1t2mle0au9/rotation.mov?dl=0
最佳答案
我必须先设置图层的框架:
self.surrounding Circles.frame = CGRectMake(0, 0, 22, 22);
关于ios - Core Animation 圆形动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26385923/