Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/98.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS 7 UINavigationController过渡到UITableView:动画期间的黑色半透明层_Ios_Objective C_Uitableview_Uinavigationcontroller_Uiviewanimationtransition - Fatal编程技术网

iOS 7 UINavigationController过渡到UITableView:动画期间的黑色半透明层

iOS 7 UINavigationController过渡到UITableView:动画期间的黑色半透明层,ios,objective-c,uitableview,uinavigationcontroller,uiviewanimationtransition,Ios,Objective C,Uitableview,Uinavigationcontroller,Uiviewanimationtransition,在我的新iOS应用程序中,我希望为整个应用程序及其视图使用固定的背景 单击导航项以显示设置表控制器时,整个屏幕上会在几分之一秒内出现一个难看的黑色半透明层或类似的东西,直到动画完成 有没有办法消除这种不受欢迎的行为? 谢谢大家! 演示: 编辑: UINavigationController包含背景图像 我的设置TableViewController修改如下: self.tableView.backgroundView = nil; self.tableView.opaque = NO; se

在我的新iOS应用程序中,我希望为整个应用程序及其视图使用固定的背景

单击导航项以显示设置表控制器时,整个屏幕上会在几分之一秒内出现一个难看的黑色半透明层或类似的东西,直到动画完成

有没有办法消除这种不受欢迎的行为? 谢谢大家!

演示:

编辑: UINavigationController包含背景图像

我的设置TableViewController修改如下:

self.tableView.backgroundView = nil;
self.tableView.opaque = NO;
self.tableView.backgroundColor = [UIColor clearColor];

这是因为iOS 7中的标准
UINavigationController
push动画。当一个新的ViewController被推到堆栈上时,它会覆盖在前一个ViewController的顶部,下面有一个轻微的阴影

我认为解决方案是实现您自己的转换。像这样:

创建一个新的
UINavigationController
类,我将其命名为
CustomNavigationController

CustomNavigationController.h

@interface UINavigationController (Retro)

- (void)pushViewControllerCustom:(UIViewController *)viewController;

@end
@implementation UINavigationController (Retro)

- (void)pushViewControllerCustom:(UIViewController *)viewController {
    CATransition *transition = [CATransition animation];
    transition.duration = 0.2;
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault];
    //Fade here look nice, no more black shadow stuff
    transition.type = kCATransitionFade;
    transition.subtype = kCATransitionFromRight;
    [self.view.layer addAnimation:transition forKey:nil];

    [self pushViewController:viewController animated:NO];
}

@end
CustomNavigationController.m

@interface UINavigationController (Retro)

- (void)pushViewControllerCustom:(UIViewController *)viewController;

@end
@implementation UINavigationController (Retro)

- (void)pushViewControllerCustom:(UIViewController *)viewController {
    CATransition *transition = [CATransition animation];
    transition.duration = 0.2;
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault];
    //Fade here look nice, no more black shadow stuff
    transition.type = kCATransitionFade;
    transition.subtype = kCATransitionFromRight;
    [self.view.layer addAnimation:transition forKey:nil];

    [self pushViewController:viewController animated:NO];
}

@end
要使用它:

- (IBAction)barButtonItemPressed:(id)sender
{
    TableViewController *tableView = [self.storyboard instantiateViewControllerWithIdentifier:@"table"];
    [self.navigationController pushViewControllerCustom:tableView];
}

谢谢,这是一个很好的解决方案:-)