结合使用UIViewControllerAnimatedTransitioning和自定义界面

时间:2019-04-18 19:05:48

标签: ios uiviewcontroller uistoryboardsegue

我已经设置了一个自定义序列来交换根视图控制器,但目前它没有动画。

@interface SwapRootSegue: UIStoryboardSegue

@end


@implementation SwapRootSegue

    - (void)perform {
        UIViewController *sourceViewController = self.sourceViewController;

        UIViewController *destinationViewController = self.destinationViewController;
        destinationViewController.view.frame = sourceViewController.view.frame;
        [destinationViewController.view layoutIfNeeded];

        UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
        keyWindow.rootViewController = destinationViewController;
    }

@end

我意识到我可以在segue本身中设置UIView动画,但是我希望它可以重用并使用可交换过渡,类似于在模态情况下视图控制器过渡如何向过渡委托者请求动画师segue,或者在进行推送segue时导航控制器委托返回一个动画制作器。

如何设置自定义序列,以便为动画使用此类UIViewControllerAnimatedTransitioning动画师(或类似动画师),然后交换根控制器?

0 个答案:

没有答案
相关问题