[英]how to execute multiple animations in a row?
-(ibaction)sometouched:(id)sender
{
[UIView beginAnimations:@"first one" context:nil];
[UIView setAnimationDuration:1.0];
[myview setFrame:CGRectMake(0,y,width.height.);
[UIView commitAnimations];
[UIView beginAnimations:@"second one" context:nil];
[UIView setAnimationDuration:1.0];
[myview setFrame:CGRectMake(x,0,width.height.);
[UIView commitAnimations];
}
這只是一個示范。 我想要的動畫將分為2部分。 第一個將視圖向下移動,第二個將視圖向右移動。 但是我得到的是它迅速向下移動,然后正確地向右移動。
我在這里想念什么?
您需要從animationDidStop委托方法開始第二個動畫。
-(ibaction)sometouched:(id)sender { [UIView beginAnimations:@"first one" context:nil]; [UIView setAnimationDuration:1.0]; [myview setFrame:CGRectMake(0,y,width.height.); [UIView setAnimationDelegate:self]; [UIView commitAnimations]; } - (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag { [UIView beginAnimations:@"second one" context:nil]; [UIView setAnimationDuration:1.0]; [myview setFrame:CGRectMake(x,0,width.height.); [UIView setAnimationDelegate:nil]; [UIView commitAnimations]; }
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.