iOS 7在导航的自定义动画中显示黑色背景

前端之家收集整理的这篇文章主要介绍了iOS 7在导航的自定义动画中显示黑色背景前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在我的iOS应用程序中使用自定义动画进行导航.

我有一个UINavigationController的子类,其中重写了以下方法

- (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; //,kCATransitionFade
    transition.subtype = kCATransitionFromRight; //kCATransitionFromLeft,kCATransitionFromBottom
    [self.view.layer addAnimation:transition forKey:@"Pop"];

    UIViewController *poppedVC = [super popViewControllerAnimated:NO];

    return poppedVC;
}

我不记得链接,但我从这里的一个问题复制了这个代码,一点点修改对我有用.

现在,当我将代码移植到iOS 7 SDK时,导航时会显示黑色背景.

我在这里发布了一个视频:Black background while navigation in iOS app,以便说清楚.

注意:我的应用程序中的要求是当推/弹时动画与默认的左右和左右相反.当我针对iOS 5并且没有显示黑色背景/屏幕时,此代码工作正常.

解决方法

在委托中添加(didFinishLaunchingWithOptions方法)这两行:
self.window.backgroundColor = [UIColor whiteColor];
self.window.tintColor = [UIColor whiteColor];
原文链接:/iOS/327798.html

猜你在找的iOS相关文章