ios - Core Animation 圆形动画

标签 ios rotation core-animation cabasicanimation

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

相关文章:

iphone - iOS 将 View 和图像编码/解码到文件目录中

rotation - 如何将 2 个四元数旋转回起始位置,然后计算相对旋转?

objective-c - 顺序核心动画的设计模式

ios - dismissViewControllerAnimated 不为 ViewController 设置动画

objective-c - UIView动画VS核心动画

ios - 无法为 iOS 应用程序版本构建存档 - 命令/bin/sh 失败,退出代码为 1

iphone - 当 recordId 不可用时,ABAddressBookGetPersonWithRecordID 会使应用程序崩溃

ios - 是否可以横向旋转 UIAlertController(和 Alert)?

iOS 7 第一次通过时不正确计算 UITableViewCell 高度

ios - UITableView 和 UITableViewHeader 在旋转和调整大小后发生冲突