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 ?
The Fade In/Fade Out behavior lets you dissolve into and out of any object by ramping the opacity of the object from 0 percent to 100 percent at the start, and then back to 0 percent at the end. You can eliminate the fade-in or fade-out effect by setting the duration of the Fade In Time or Fade Out Time to 0 frames.
Fade in effect can be used to display new video information from a static background. In case of matrix switching, this means visualization of a new video signal to a certain output. On the output the visitor may see the static and still background first and the video signal comes up smoothly.
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]];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With