3

是否可以控制segue速度?

我已经检查了文档,但 Apple 没有给出任何方法。

但我更多的是寻找破解和更改较低级别代码以进行慢动作连续的想法

4

2 回答 2

5

下面的代码是自定义的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

您可以下载并运行它。我希望这对你有帮助。

于 2012-08-05T06:52:36.313 回答
0

为了防止僵尸的产生,我认为最好也使用子视图添加/删除:

- (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;
                    }];
}

这是如果您不使用导航控制器!

于 2014-03-28T17:01:38.210 回答