第16月第12天 CABasicAnimation 旋转加速

时间:2022-09-04 22:19:31

1.

int count = ;
double duration = 10.0f;
for (int i=; i<count; i++) {
//旋转动画
CABasicAnimation *anima3 = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
anima3.toValue = [NSNumber numberWithFloat:M_PI*];
anima3.beginTime = (1.0/count)*duration*i;
anima3.duration = (1.0/count)*duration;
if (i == ) {
anima3.speed = ;
} else {
anima3.speed = i+;
anima3.repeatCount = i+;
} [arr addObject:anima3];
}
//组动画
CAAnimationGroup *groupAnimation = [CAAnimationGroup animation];
groupAnimation.animations = arr;//[NSArray arrayWithObjects:anima3, nil];
groupAnimation.duration = duration;
groupAnimation.removedOnCompletion = NO; [self.layer addAnimation:groupAnimation forKey:@"groupAnimation"];