Views get darker when clicked on by the navigation controller

I click ViewControllers on the NavigationController by segues. I have my own subclassified navigation controller that inserted UIImageView at index 0 - this is the background for my entire application.

The problem is that I see that when the new view controller approaches the screen on the right side, at first it looks like there is some light dark overlay that disappears when right after viewDidApear is called.

Each view controller has self.view.backgroundColor = [UIColor clearColor] . If I change it for now, everything is fine. Maybe I should set the background of the application in a different way? And if not, how to avoid this dark color effect?

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

+7
ios objective-c uiviewcontroller uinavigationcontroller transitions
source share
2 answers

This is because of the standard UINavigationController push animation in iOS 7. When a new VC is pushed onto the stack, it overlays on top of the previous VC with a slight shadow below it. That way, when you click on your viewControllers that have clear backgrounds, you see through the shadow when the transition occurs.

There are several possible solutions:

  • Set the background color on your viewing monitor (maybe this is not an option for you because of the global background image). The simplest solution, but will require a change in your design.
  • Deploy your own migration with the new iOS 7 APIs. See here and the Big Nerd Ranch article here . This is really the โ€œrightโ€ solution to your problem if you want to keep a background image.
  • Add the UINavigationController category to add a simpler โ€œretroโ€ push and pop animation, according to this answer . It is rather a quick and hacky solution.
+3
source share

I created a custom push segue that should do the job:

ClearBkgPushSegue.h:

 #import <UIKit/UIKit.h> @interface ClearBkgPushSegue : UIStoryboardSegue @end 

ClearBkgPushSegue.m:

 #import "ClearBkgPushSegue.h" @implementation ClearBkgPushSegue -(void)perform { UIViewController *sourceViewController = self.sourceViewController; UIViewController *destinationViewController = self.destinationViewController; CGRect bounds = [[UIScreen mainScreen] bounds]; UIWindow *window = [[[UIApplication sharedApplication] delegate] window]; UIView *destView = destinationViewController.view; [window insertSubview:destinationViewController.view aboveSubview:sourceViewController.view]; destView.frame = CGRectMake(bounds.size.width, destView.frame.origin.y, destView.frame.size.width, destView.frame.size.height); [UIView animateWithDuration:.35 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{ destView.frame = sourceViewController.view.frame; sourceViewController.view.frame = CGRectMake([UIScreen mainScreen].bounds.size.width * -0.33, 0.0, sourceViewController.view.frame.size.width, sourceViewController.view.frame.size.height); sourceViewController.view.alpha = 0; } completion:^(BOOL finished) { [sourceViewController.navigationController pushViewController:destinationViewController animated:NO]; sourceViewController.view.alpha = 1; }]; } @end 

Just select your segue as โ€œCustomโ€ and select this class and you will go well.

0
source share

All Articles