Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Views getting darker when are pushed on navigation controller

I'm pushing ViewControllers on NavigationController by segues. I have my own subclassed NavigationController which has inserted UIImageView at index 0 - it's a background for my entire application.

The problem is that I can see that when new view controller is coming to the screen from the right side, in the beginning it's like having some light dark overlay which is disappearing when just after viewDidApear is called.

Every view controller has a self.view.backgroundColor = [UIColor clearColor]. If i change it for while, everything is fine. Maybe i should set background of application in another way? And if not, how to avoid this darkling effect?

Here you have screen capture with this effect: http://tinypic.com/r/34j9ffs/8

like image 698
krzysiek Avatar asked Jan 29 '14 09:01

krzysiek


People also ask

What is navigation controller how it is helpful when working with multiple controllers?

A navigation controller coordinates its behavior with its delegate object. The delegate object can override the pushing or popping of view controllers, provide custom animation transitions, and specify the preferred orientation for the navigation interface.

Is UINavigationController a UIViewController?

A UINavigationController does a lot of this tedious work for you. As mentioned, it contains a stack of UIViewControllers. It will create a navigation bar at the top that will allow you to easily go back up the hierarchy of view controllers.

What is navigation controller in iOS?

The Navigation Controller can be defined as the container view controller that maintains a stack of View Controllers for navigating hierarchical content. It is an instance of the UINavigationController class, which inherits UIViewController. class UINavigationController : UIViewController.


1 Answers

It's because of the standard UINavigationController push animation in iOS 7. When a new VC is pushed onto the stack, it overlays itself on top of the previous VC, with a slight shadow underneath it. As such, when you push your viewControllers which have clear backgrounds, you see through to the shadow when the transition takes place.

There are a couple of possible solutions:

  • Set a background colour on your viewControllers (probably not an option for you because of your global background image). The simplest solution, but would require a change to your design.
  • Implement your own transition using the new iOS 7 APIs. See an example here and an article from Big Nerd Ranch here. This is really the 'proper' solution to your problem if you want to keep your background image.
  • Add a UINavigationController category to add a simpler 'retro' push and pop animation, as per this answer. This is more of a quick and hacky solution.
like image 168
James Frost Avatar answered Sep 28 '22 16:09

James Frost