Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS7 Custom Transitions with UINavigationController

I am using the iOS7 custom transitions to modally present a new view controller.

The new view controller is a navigation controller.

The controller animates up from the bottom, while the background view blurs.

My issue is that the navigation bar on the new controller, while animating upwards, appears to allows for a status bar, ie it seems to be 64 points high. When it has reached its final location and called completeTransition it realises no status bar space is required and snaps back to 44 points.

Is there a way to

  • Initially inform the nav controller/top view controller that no status bar is required. OR
  • Call whatever method that completeTransition is calling before the animation so that the automatic re-adjusting takes place then.

While animating:

While animating

Animation complete:

Animation complete

like image 948
Alan Avatar asked Mar 23 '23 02:03

Alan


1 Answers

The trick was to add the view of the presented view controller to the container view AFTER setting its initial position off the bottom of the screen. This prevents the container view from thinking it is at the top of the screen and automatically laying out with status bar provision accordingly.

It is related to the following from WRESTLING WITH STATUS BARS AND NAVIGATION BARS ON IOS 7:

"UINavigationController will alter the height of its UINavigationBar to either 44 points or 64 points, depending on a rather strange and undocumented set of constraints. If the UINavigationController detects that the top of its view’s frame is visually contiguous with its UIWindow’s top, then it draws its navigation bar with a height of 64 points. If its view’s top is not contiguous with the UIWindow’s top (even if off by only one point), then it draws its navigation bar in the “traditional” way with a height of 44 points. This logic is performed by UINavigationController even if it is several children down inside the view controller hierarchy of your application. There is no way to prevent this behavior."

like image 181
Alan Avatar answered Mar 31 '23 19:03

Alan