![](/img/trans.png)
[英]WebApp on iPhone with black-translucent StatusBar: Viewport height seems to be wrong
[英]iOS 7 UINavigationController transition to UITableView: black-translucent layer during animation
在我的新iOS应用中,我想为整个应用及其视图使用固定的背景。
当单击导航项以显示设置表控制器时,丑陋的黑色半透明层或类似的东西在整个屏幕上的显示时间不到一秒钟,直到完成动画为止。
是否有消除这种不良行为的想法? 谢谢!
演示:
编辑: UINavigationController包含背景图像。
我的设置TableViewController修改如下:
self.tableView.backgroundView = nil;
self.tableView.opaque = NO;
self.tableView.backgroundColor = [UIColor clearColor];
这是因为iOS 7中使用了标准的UINavigationController
推送动画。将新的ViewController推送到堆栈上时,它将自身覆盖在以前的ViewController的顶部,并在其下方有一个阴影。
我认为解决方案是实施您自己的过渡。 像这样:
创建一个新的UINavigationController
类,我将其命名为CustomNavigationController
CustomNavigationController.h
@interface UINavigationController (Retro)
- (void)pushViewControllerCustom:(UIViewController *)viewController;
@end
CustomNavigationController.m
@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];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.