-(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个部分。第一个向下移动视图,第二个向右移动视图。但我得到的是它迅速向下移动然后向右移动。
我在这里想念的是什么?
答案 0 :(得分:1)
您需要从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]; }