Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 7 shows black background in custom animation for Navigation

I am using custom animation for navigation in my iOS app.

I have a subclass of UINavigationController in which the following methods are overridden:

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    CATransition* transition = [CATransition animation];
    transition.duration = 0.4;
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault];
    transition.type = kCATransitionPush;//kCATransitionFade; //kCATransitionMoveIn; //, kCATransitionPush, kCATransitionReveal, kCATransitionFade
    transition.subtype = kCATransitionFromLeft; //kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom
    [self.view.layer addAnimation:transition forKey:@"Push"];

    [super pushViewController:viewController animated:NO];
}

- (UIViewController *)popViewControllerAnimated:(BOOL)animated
{
    CATransition* transition = [CATransition animation];
    transition.duration = 0.4;
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault];
    transition.type = kCATransitionPush;//kCATransitionFade; //kCATransitionMoveIn; //, kCATransitionPush, kCATransitionReveal, kCATransitionFade
    transition.subtype = kCATransitionFromRight; //kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom
    [self.view.layer addAnimation:transition forKey:@"Pop"];

    UIViewController *poppedVC = [super popViewControllerAnimated:NO];

    return poppedVC;
}

I don't remember the link but I had copied this code from a question in here and a little modification had worked for me.

Now when I ported my code to iOS 7 SDK, there is a black background shown while navigation.

I posted a video here: Black background while navigation in iOS app to make it clear.

Note: The requirement in my app is that animation be the opposite of the default right-left and left-right when push/pop. This code was working perfectly when I was targeting iOS 5 and there was not black background/screen shown.

like image 677
Abdullah Umer Avatar asked Nov 19 '13 13:11

Abdullah Umer


1 Answers

Add in the delegate (didFinishLaunchingWithOptions method) these two lines :

self.window.backgroundColor = [UIColor whiteColor];
self.window.tintColor = [UIColor whiteColor];
like image 149
Lilo Avatar answered Oct 13 '22 04:10

Lilo