How to change speed of segue between ViewControllers

♀尐吖头ヾ 提交于 2019-12-04 12:12:40

Below code is of custom segue, and you can set duration of transition in code.

- (void)perform 
{
    UIViewController *src = (UIViewController *) self.sourceViewController;
    UIViewController *dst = (UIViewController *) self.destinationViewController;
    [UIView transitionFromView:src.view
                        toView:dst.view
                      duration:3.0
                       options:UIViewAnimationOptionTransitionFlipFromLeft
                    completion:NULL];

}

Sample project is here in GitHub:https://github.com/weed/p120805_CustomSegue

You can download and just run it. I wish this is help for you.

to prevent zombies creation i think better to do use subview add/remove as well:

- (void)perform
{
    UIView *src = ((UIViewController *) self.sourceViewController).view;
    UIView *dst = ((UIViewController *) self.destinationViewController).view;

    UIWindow *window = [[[UIApplication sharedApplication] delegate] window];
    [window insertSubview:dst aboveSubview:src];

    [UIView transitionFromView:src
                        toView:dst
                      duration:1.5
                       options:UIViewAnimationOptionTransitionCrossDissolve
                    completion:^(BOOL finished){
                        [src removeFromSuperview];
                        window.rootViewController = self.destinationViewController;
                    }];
}

this is if you are not using navigation controller!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!