Ste*_*lot 3 iphone cocoa-touch core-animation
我想连续使用旋转图层byValue,但我无法使其正常工作.我想每秒旋转6度,在60秒内完全旋转.
如果图层的初始旋转为0,则一切正常.
问题是当我尝试设置初始值时fromValue.如果我设置fromValue为90度,动画将从90度旋转到90 + 6,然后跳转到90+(90 + 6),动画和再次跳转.
任何的想法?
CABasicAnimation* animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
animation.fromValue = [NSNumber numberWithDouble:M_PI_2];
animation.byValue = [NSNumber numberWithDouble:6.0f*M_PI/180.0f];
animation.toValue = nil;
animation.fillMode = kCAFillModeForwards;
animation.cumulative = YES;
animation.additive = NO;
animation.repeatCount = 10000;
animation.removedOnCompletion = YES;
animation.duration = 1.0;
[myLayer addAnimation:animation forKey:@"transform"];
Run Code Online (Sandbox Code Playgroud)
这对我有用:
CABasicAnimation* animation = [CABasicAnimation animationWithKeyPath: @"transform"];
CATransform3D transform = CATransform3DMakeRotation (DegreesToRadians (90), 0, 0, 1);
animation.toValue = [NSValue valueWithCATransform3D: transform];
animation.duration = 60;
animation.cumulative = NO;
animation.repeatCount = 10000;
animation.removedOnCompletion = YES;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6520 次 |
| 最近记录: |