ccnyou
ccnyou

Reputation: 347

iOS UINavigationController push/pop cross horizontal cover animation

The pushed controller cross over current controller.

Results are as follows: enter image description here image 0

Actually, I have hook into this app, it use a subclass named MMUINavigationController, and I am sure current action is "pushViewController:animated:", it's the interface I hooked.

Tweak.xm: enter image description here image 1

alertView: enter image description here image 2

how to make it ?

additional,standar animation:

enter image description here

image 3

navigation bar of pushed controller

5

image 4

Upvotes: 0

Views: 375

Answers (1)

DAN
DAN

Reputation: 939

Here's one solution:

  1. hide the navigation bar of the navigation controller
  2. add a navigation bar to the root view controller of the navigation controller
  3. restore the swipe to back gesture to the navigation controller

For the last point you can add a pan gesture recognizer (suggested) or simply set the interactivePopGestureRecognizer's delegate of the navigation controller to nil:

self.navigationController?.interactivePopGestureRecognizer?.delegate = nil;

but please refer to this discussion for its implications: No Swipe Back when hiding Navigation Bar in UINavigationController

EDIT:

Working solution which fulfills the requirements: just setting the navigationBarHidden in the viewWillAppear does the magic.

I've setup a sample demo here: https://github.com/ldantona/NavigationBarExample

EDIT 2:

Just found this library, could it be of any help? https://github.com/MoZhouqi/KMNavigationBarTransition

The library can capture the background style of the navigation bar in the disappearing view controller when pushing, and when you pop back to the view controller, the navigation bar will restore the previous style, so you don't need to consider the background style after popping. And you also don't need to consider it after pushing, because it is the view controller to be pushed that needs to be considered.

Hope it helps

Upvotes: 1

Related Questions