自定义Segue动画显示黑屏

时间:2014-05-27 13:00:27

标签: ios objective-c uistoryboardsegue catransition

我遇到了一个新问题,在使用自定义segue呈现destinationViewController时,在转换期间,源ViewController更改为黑屏,我需要屏幕保持不变(我的设计) )。

UIViewController *sourceViewController = (UIViewController*)[self sourceViewController];
UIViewController *destinationController = (UIViewController*)[self destinationViewController][screenshot][1]

CATransition* transition = [CATransition animation];
transition.duration = 0.1;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush; //kCATransitionMoveIn; //, kCATransitionPush, kCATransitionReveal, kCATransitionFade
transition.subtype = kCATransitionFromRight; //kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom


[destinationController.view.layer addAnimation:transition forKey:kCATransition];
[sourceViewController presentViewController:destinationController animated:NO completion:nil];

1 个答案:

答案 0 :(得分:2)

我认为你需要保持上下文,试试这个:

    UIViewController *rootViewController = [UIApplication sharedApplication].delegate.window.rootViewController;
    rootViewController.modalPresentationStyle = UIModalPresentationCurrentContext;
    UIViewController *destinationController = (UIViewController*)[self destinationViewController]
    [sourceViewController presentViewController:destinationController animated:NO completion:nil];