i implemented the method in ViewController A
- (BOOL)prefersStatusBarHidden {
return NO;
}
i implemented the method in ViewController B
- (BOOL)prefersStatusBarHidden {
return YES;
}
- (UIStatusBarAnimation)preferredStatusBarUpdateAnimation {
return UIStatusBarAnimationSlide; // when doing hiding animation i want it to slide up
}
i implemented a class T
that conforms for viewController transitioning say AtoBTransition
, i used this ViewControllerTransition for Transitioning From vc(viewcontroller) A to vc B. when transitioning to vc B i want the status bar to slide up (hide with sliding animation)
but in this case, it seems that it doesn't do that the sliding animation.
Questions: Just Assume that i didn't do UIStatusBar related code in class T
, and didn't add the value View controller-based status bar appearance
in info plist. And transition T
works perfectly as needed.
i'm sure the code reads in -preferredStatusBarUpdateAnimation
by doing breakpoint or logging but why it didn't hiding statusbar animation by sliding? when i toggle to slowmotion in simulator. it appears it doesn't do animation.
my theory is that it conflicts with transition animation context, so is it possible to do animation of hiding UIStatusBar within the implementation of T
as part of its transition scheme?
is it possible to do UIStatusBar animation along with ViewControllerAnimationTransition?
feel free to clear some stuff. thanks ahead.. :)
I don't think you can do this directly with iOS 7 's view controller transition API.
Now, I'm assuming based on the hooks to this API and the status bar API that the status bar is an animal unto itself and is not available for animating with a custom transition. I think this is the case because when the UIViewControllerContextTransitioning
transitionContext is created for you view controller A is already added to it's containerView
and because you're responsible for adding view controller B to the containerView
(because you need to transition to it) all of view controller B's status bar manipulation methods are fired when you do so.
However, you can animate UIApplication
's keyWindow
's frame during your animation transition So in the -animateTransition:
method of your class that implements UIViewControllerAnimatedTransitioning
.
[UIView animateWithDuration:[self transitionDuration:transitionContext] delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
[UIApplication sharedApplication].keyWindow.frame = CGRectMake(0, 0, 320, 568); // move frame up
} completion:^(BOOL finished) {
// assuming
[UIApplication sharedApplication].keyWindow.frame = CGRectMake(0, 20, 320, 568); //move frame down
}];
If you go with this approach, you'll probably need to adjust the frame of the key window in view controller A to drop below the status bar and be styled light/dark as needed. Then do the opposite to get the effect you want in view controller B. Its nasty, but it could work.
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