我有一个小的 UIView,想让它先移动到屏幕中心,然后缩放到全屏。 但是当我开始启动像
这样的动画[UIView beginAnimations:@"animation1" context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(showDetailToFullscreen)];
self.currentDetailVC.frame = centerFrame;
[UIView commitAnimations];
在同一个 Controller 中,我有一个方法:showDetailToFullscreen
- (void)showDetailToFullscreen {
CGRect screenFrame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height);
[UIView beginAnimations:@"animation2" context:nil];
[UIView setAnimationDuration:0.5];
self.currentDetailVC.view.frame = screenFrame;
[UIView commitAnimations];
}
但是启动的时候还是一起执行的。 我认为他们的问题仍然在同一笔交易中。但怎样才能让这两个动画一一执行呢?感谢您的任何回答!
最佳答案
试试这个而不是 setAnimationDidStopSelector:
[self performSelector:@selector(showDetailToFullscreen) withObject:nil afterDelay:0.5];
关于objective-c - 如何让UIView的两个动画一一执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5665990/