我正在使用[UIView transitionWithView:]
进行动画制作。
此方法只有delay
持续时间,但我需要延迟一些。
例如:需要将1个图像更改为另一个图像,持续时间为1秒,然后在4秒后将图像更改为另一个图像,持续时间为1秒。
我知道有[UIView animateWithDuration:]
delay
[UIView transitionWithView:self.view
duration: 1.0f
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{
//here change image
} completion:^(BOOL finished){
[NSThread sleepForTimeInterval: 4.0f];
}];
但我没有更改框架,它不会更改图像超过1次。
我使用下一个:
[NSThread sleepForTimeInterval: 4.0f];
工作正常。但是我改变了视图(我有滚动视图并添加了很多带动画的视图)它显示了另一个视图,它是自己的动画,但是前一页的{{1}}正在处理它。
那我怎么能延迟动画?
感谢您的帮助!
答案 0 :(得分:1)
我个人喜欢依赖计时器。他们不会挂起应用程序,让您更灵活地控制触发器。
NSTimer *mytimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(myAnimationFunction:) userInfo:nil repeats:NO];
-(void) myAnimationFunction:(NSTimer *)timer{<br>
// Do anything here...<br>
}