简体   繁体   English

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

[英]iOS 7 UINavigationController transition to UITableView: black-translucent layer during animation

in my new iOS app I'd like to use a fixed background for the entire app and its views. 在我的新iOS应用中,我想为整个应用及其视图使用固定的背景。

When clicking the navigation item to show up the settings table controller an ugly black-translucent layer or something like this appears in a fraction of a second on the whole screen until the animation is done. 当单击导航项以显示设置表控制器时,丑陋的黑色半透明层或类似的东西在整个屏幕上的显示时间不到一秒钟,直到完成动画为止。

Any idea to remove this undesired behaviour? 是否有消除这种不良行为的想法? Thank you! 谢谢!

Demo: 演示:

图片

better .mp4 version of the demo @ Dropbox 更好的.mp4版本的演示@ Dropbox

edit: The UINavigationController contains the background image. 编辑: UINavigationController包含背景图像。

My Settings TableViewController was modified like this: 我的设置TableViewController修改如下:

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

It's because of the standard UINavigationController push animation in iOS 7. When a new ViewController is pushed onto the stack, it overlays itself on top of the previous ViewController, with a slight shadow underneath it. 这是因为iOS 7中使用了标准的UINavigationController推送动画。将新的ViewController推送到堆栈上时,它将自身覆盖在以前的ViewController的顶部,并在其下方有一个阴影。

The solution I think is to implement your own transition. 我认为解决方案是实施您自己的过渡。 Like this: 像这样:

Create a new UINavigationController class, I name it CustomNavigationController 创建一个新的UINavigationController类,我将其命名为CustomNavigationController

CustomNavigationController.h CustomNavigationController.h

@interface UINavigationController (Retro)

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

@end

CustomNavigationController.m 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

To use it: 要使用它:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 带有黑色半透明状态栏的 iPhone 上的 WebApp:视口高度似乎是错误的 - WebApp on iPhone with black-translucent StatusBar: Viewport height seems to be wrong 动画ios应用程序中的黑色过渡 - black transition in animation ios app 对子类UINavigationController使用自定义iOS 7过渡有时会导致黑屏 - Using custom iOS 7 transition with subclassed UINavigationController occasionally results in black screen UIViewController 边缘在 UINavigationController animation 期间未延伸到顶/底栏后面(如果它具有半透明 UIToolbar 子视图) - UIViewController edges not extended behind top/bottom bars during a UINavigationController animation if it has a translucent UIToolbar subview iOS - 在动画过渡期间更新标签? - iOS - Updating label during animation transition? iOS 8将状态栏设为黑色且不透明 - iOS 8 make statusbar black and not translucent iOS 深色键盘在 UINavigationController 推送/弹出动画期间具有背景 - iOS Dark Keyboard has background during UINavigationController push/pop animation 推送到UINavigationController时停止UITableView Animation - Stop UITableView Animation on push to UINavigationController 如何在iOS uitableview deleteRowsAtIndexPaths上增加动画过渡秒数 - How to increase animation transition seconds on ios uitableview deleteRowsAtIndexPaths 使用UINavigationController进行iOS 7自定义当前转换 - iOS 7 Custom Present Transition with UINavigationController
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM