Segue Push Animation with Clear Background is Flas

2019-06-21 15:55发布

I have this simple storyboard :

enter image description here

all of those UIViewController background are clear (transparent), but I put background image as navigation bar and window background using this code :

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{      
    // window background
    self.window.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"window"]];

    // navbar background
    UIImage *navBackgroundImage = [UIImage imageNamed:@"navbar_bg"];
    [[UINavigationBar appearance] setBackgroundImage:navBackgroundImage forBarMetrics:UIBarMetricsDefault];
    [[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
    return YES;
}

usually this code works on iOS 6 without flashing, but today when I try to build it on iOS 7, the segue animation (push) is flashing. It seems that the UIViewController background is not fully transparent.

please take a look at this video : http://www.youtube.com/watch?v=-oZc9SwPJjs

thank you

1条回答
姐就是有狂的资本
2楼-- · 2019-06-21 16:42

I faced the same problem some time ago, view controllers with transparent background makes this "effect", that actually is not a flash, it is the animation of the view sliding over the other view. The only way to solve this is removing the animation of the push, indeed I don't think you need this animation, so take a look on the answer of this question, it shows how to change it:

Change animation transition

Or take a look on this, he has a sample code, that you can just download and see how it works:

http://www.captechconsulting.com/blog/tyler-tillage/ios-7-tutorial-series-custom-navigation-transitions-more

Hope it helps!

查看更多
登录 后发表回答