Detect UINavigationController anmation complete when subView covers the current view - ios

I have a view being shown in a navigation controller. I have added a subview to the navigation controller's view so that it covers up all of the view that is being shown except for the navigation bar itself. The subView has been added like -
'[self.navigationController addSubView:mySubView];'
On some action on the subView, I want to to do the following in sequence-
Pop the current view controller on the navigation stack with animation and then.
After the view controller is popped and the animation is complete, remove the subview from the navigation controller view
The reason why I need to do this is that I need to show the animation of the navigation bar title before removing the sub view.
So I would like to get the event of navigation controller animation completed and then remove the subView.
viewDidAppear, viewWillAppear or navigationController:didShowViewController:animated: do not help, as the subView covers the underlying view on the navigation stack and these methods never get called.
Currently I am just removing the subview after a delay hoping that the animation has completed. But I know that this is not a reliable way to do what I want.
Is there any other way that I can accomplish the sequence of events that I need?

Subclass the navigation controller, and implement the delegate method, navigationBar:didPopItem:, which is called after the navigation bar animation is completed. You can remove your subview in that method.

Related

How to hide a custom navigation bar with animation in Modal view controller

I made a view controller with collection view and presented it modally. And I also added custom navigation bar and toolbar without navigation controller because I want to present the view controller modally as I said.
So I can't have navigationController property on the view controller and can't use setNavigationBarHidden(_:animated:) that I exactly wanted.
I temporarily set isHidden of each bar to false & true whenever tapping a screen. But I heard I shouldn't use isHidden property directly, and I still want to do that with animation.
Any solution? Did I miss something?
Do I just use UIView.animate method?
Main.storyboard

Transition from one view controller to another with a change in colour of navigation bar

I have the same navigation bar in multiple viewcontrollers. When i push from one view controller to another the colour of the view controller changes, but the transition is awful. How can I achieve smooth transition? I cant find a proper code to make this work in swift.
If you make the transition in viewWillAppear of the view controller getting pushed on and then change it back in viewWillAppear of the the first view controller that should make the transition smoother.
If you want to get fancier you could try and put it in a UIView.animateWithDuration block and animate the changes while the navigation controller is animating the transitions.

Keep UIView while animating navController

How can I animate in a new uinavigation controller but keep the same uiview in the window?
I've seen this done in the opposite - a navController stay in place while a container view changes a view controller as a child view controller, but I want the opposite:a main view, a mapview, to remain in the window at all times while a new vc2 slides in from a push segue which will show a different navBar title and uibarbutton items. This is important because I need the mapview from VC1 to replicate in VC2, or to that effect.
Can this be done and how? Thank you for suggestions all,
It would probably be better to do this without a navigation controller. You can create a custom container controller with a navigation bar at the top. You can add vc2 as a child of your container controller, remove the map view from vc1, add it to the view of vc2, and remove vc1 from the container controller. This would all be done with no animation, so the user shouldn't see anything happening in the main view. You can call pushNavigationItem:animated: on the navigation bar to animate in the new navigation item.

iOS 7 universal background UIViewController

I am trying to set up a UIViewController in my app which always remains in the background of all other UIViewControllers. What I want it to do is display a repetitive animation continuously in the background, unaffected my transitions and navigations in the UIViewControllers in the foreground. Can anybody suggest a good method to do this?
You could create your own UINavigationController and add your animation view to its background in the viewDidLoad method
self.view insertSubview:myAnimatedView atIndex:0
And make sure that your other viewcontollers are transparent.
See also https://stackoverflow.com/a/13096911/443270
Make a view controller that will have your background view and animation as your root view controller. Then make the view controller that you want to control the rest of your app (we'll call it your navigation controller). Add the view of your navigation controller as a subview of your background view controller.
edit:
You can't do this with tab bar controllers as they must be the root view controller.
start with a subclassed UINavigationController with your animation on ViewDidLoad
push the viewcontrolelrs on this subclassed NavController
example from my github page
https://github.com/mako34/backgroundNavController

How to fade whole screen

I am presenting a temporary view on top of my view controller when a user does some action.
I want it to fade the screen - including the navigation bar, like UIActionSheet does.
I am presenting the view via the root view controller of the navigation controller, so my only problem is to fade also the navigation bar and not allow touches on it.
How can I do that?
You can add a semi-transparent view on the whole UIWindow and it'll look just as you described it. You'd probably want to add your temporary view there, too, because all actions will be blocked by the semi-transparent view.

Resources