gpt4 book ai didi

ios - Core Animation 圆形动画

转载 作者:行者123 更新时间:2023-11-28 21:56:21 25 4
gpt4 key购买 nike

我一直在尝试制作一个圆形 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com