如果你一定要做好这件事情处理图层,那么你可以尝试像下面
在CATransactions
-(void)animateThreeAnimationsOnLayer:(CALayer*)layer animation:(CABasicAnimation*)firstOne animation:(CABasicAnimation*)secondOne animation:(CABasicAnimation*)thirdOne{
[CATransaction begin];
[CATransaction setCompletionBlock:^{
[CATransaction begin];
[CATransaction setCompletionBlock:^{
[CATransaction begin];
[CATransaction setCompletionBlock:^{
//If any thing on completion of all animations
}];
[layer addAnimation:thirdOne forKey:@"thirdAnimation"];
[CATransaction commit];
}];
[layer addAnimation:secondOne forKey:@"secondAnimation"];
[CATransaction commit];
}];
[layer addAnimation:firstOne forKey:@"firstAnimation"];
[CATransaction commit];
}
另一种方式是采用完工座延迟开始动画。
-(void)animateThreeAnimation:(CALayer*)layer animation:(CABasicAnimation*)firstOne animation:(CABasicAnimation*)secondOne animation:(CABasicAnimation*)thirdOne{
firstOne.beginTime=0.0;
secondOne.beginTime=firstOne.duration;
thirdOne.beginTime=firstOne.duration+secondOne.duration;
[layer addAnimation:firstOne forKey:@"firstAnim"];
[layer addAnimation:secondOne forKey:@"secondAnim"];
[layer addAnimation:thirdOne forKey:@"thirdAnim"];
}
,如果你要使用的UIView动画
//if View is applicable in your requirement then you can look this one;
-(void)animateThreeAnimationOnView{
[UIView animateWithDuration:2.0 animations:^{
//first Animation
} completion:^(BOOL finished) {
[UIView animateWithDuration:2.0 animations:^{
//Second Animation
} completion:^(BOOL finished) {
[UIView animateWithDuration:2.0 animations:^{
//Third Animation
}];
}];
}];
}