如何在ViewControllers之间改变segue的速度
是否可以控制segue速度?
我已经检查了文档,但Apple没有给出任何方法。
但我更多的是寻找破解和改变低级代码的想法,以便在慢动作中进行猜测。
下面的代码是自定义segue,您可以在代码中设置转换的持续时间 。
- (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]; }
示例项目在GitHub中: https : //github.com/weed/p120805_CustomSegue
您可以下载并运行它。 我希望这对你有所帮助。
为了防止僵尸创建我认为最好使用子视图添加/删除:
- (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; }]; }
这是如果你不使用导航控制器!