How to change speed of segue between ViewControllers

╄→尐↘猪︶ㄣ 提交于 2019-12-12 08:57:00

问题


Is it possible to control segue speed?

I have checked the documentation but there is no given method by Apple.

But I am more looking for ideas to hack in and change lower level code to make segueing in slow motion.


回答1:


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.




回答2:


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!



来源:https://stackoverflow.com/questions/11813121/how-to-change-speed-of-segue-between-viewcontrollers

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