本文介绍了X code自定义动画赛格瑞的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个故事板控制器之间的过渡动​​画的一个问题。
我有在故事板两种查看控制器一个singleView项目。

I have a problem with the transition animation between two storyboard controllers. I have a singleView project with two view controllers in the storyboard.

现在我的魔杖使自定义过渡动画:

Now I wand to make a custom transition animation:


  • 我的当前视图控制器应消失向左

  • 新的视图控制器应该来自右

我已经有一个 UIStoryboardSegue 类。

但我应该写在 - (无效)执行{} 方法??

But what should I write in the -(void)perform{} method??

非常感谢,

乔纳斯。

推荐答案

对于简单的赛格瑞你可以尝试这样的事:

For that simple segue you can try something like this:

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

    CGRect sourceFrame = source.view.frame;
    sourceFrame.origin.x = -sourceFrame.size.width;

    CGRect destFrame = destination.view.frame;
    destFrame.origin.x = destination.view.frame.size.width;
    destination.view.frame = destFrame;

    destFrame.origin.x = 0;

    [source.view.superview addSubview:destination.view];

    [UIView animateWithDuration:1.0
                     animations:^{
                         source.view.frame = sourceFrame;
                         destination.view.frame = destFrame;
                     }
                     completion:^(BOOL finished) {
                         UIWindow *window = source.view.window;
                         [window setRootViewController:destination];
                     }];
}

这篇关于X code自定义动画赛格瑞的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 07:50