界面旋转期间的淡入/淡出 [英] Fade-in / fade-out during an interface rotation
本文介绍了界面旋转期间的淡入/淡出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我的iPhone界面旋转时,我想为UIViewController的特定UIView做淡入/淡出......就像......
When my iPhone interface rotates, I would like to do a fade-in/fade-out for a specific UIView of a UIViewController... Like...
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.3];
theView.alpha = 0;
[UIView commitAnimations];
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.3];
theView.alpha = 1;
[UIView commitAnimations];
}
但动画在旋转开始之前没有完成(我们可以看到查看开始自我调整大小)...
But the animation doesn't finish before the rotation start (we can see the view starting to self-resize)...
有没有办法延迟轮换开始?
Is there a way to delay rotation start ?
持续时间是旋转动画的持续时间,对吗?
"duration" is the duration of the rotating animation, right ?
推荐答案
我发现运行当前运行循环的数量相同时间作为前面的动画,确实延迟了旋转。
I found that running the current run loop for the same amount of time as the preceding animation, did in fact delay the rotation.
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
[UIView animateWithDuration:0.25 animations:^{
theview.alpha = 0.0;
}];
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.25]];
}
这篇关于界面旋转期间的淡入/淡出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文