krzysiek krzysiek - 1 year ago 64
Objective-C Question

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

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
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:

Answer Source

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.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download