iOS 7 universal background UIViewController - ios

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

Related

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.

Sharing a common background image in a UINavigationController hierarchy?

I know it's possible to set a background image for the UINavigationBar, but I would like to know if there is a way to share a common background view for all controllers in a UINavigationController. The idea is to have a UIImageView as the background that stays in place rather than "sliding" over itself when navigating to a new controller.
A navigation controller is a kind of view controller and it hosts the currently visible view controller by adding the VC view to its view. You can add things to that view too. Create your image view and add it as a subview of the nav controller view, then send it to the back (or insert at index 0).

Detect UINavigationController anmation complete when subView covers the current view

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.

Using iOS 6 autolayout, what would be the proper way to display somthing above an UINavigationController?

In my app, i have a main view controller which sometimes brings a modal view on top of it. This modal view is a UINavigationController with a navigation bar. I want to display an image above the navigation bar, and have the navigation bar appear below the image.
I do not want to subclass anything and the app uses autolayout, i do not want a bunch of delegate callbacks and frame calculations. The view inside the navigation controller (the actual modal content) must still respond to different screen sizes correctly, such as rotation, call status bar etc. Also, no IB solutions please, these views are all managed in code.
How do i accomplish this?
I would turn off AutoLayout and place the image at the top
I don't think you can do it with your modal view being a navigation controller. I would do it by making that modal controller a UIViewController that you set up as a custom container controller. You can add an image view to the top of this controller's view and add the view of a child view controller (which would be a navigation controller) to the bottom. This would be a lot easier to do in a storyboard using container views, but it certainly can be done in code.

Resources