自定义故事板Segue

时间:2014-04-07 18:23:21

标签: ios objective-c segue

我有一个自定义的故事板segue动画,但它没有按照我想要的方式出现。而不是"擦拭"在视图控制器上,我想要它" push"离开当前视图控制器旁边的新视图控制器。 (不像推送segue,更像是在照片照片时在照片应用中看到的效果)。有任何想法吗?感谢。

- (void)perform {

UIViewController *currentViewController = self.sourceViewController;
UIViewController *newViewController = self.destinationViewController;


[currentViewController.view addSubview:newViewController.view];


newViewController.view.transform = CGAffineTransformMakeScale(0.05, 0.05);


CGPoint originalCenter = newViewController.view.center;

newViewController.view.center = self.originatingPoint;

[UIView animateWithDuration:1.9
                      delay:0.0
                    options:UIViewAnimationOptionCurveEaseInOut
                 animations:^{

                     newViewController.view.transform = CGAffineTransformMakeScale(1.0, 100.0);
                     newViewController.view.center = originalCenter;
                 }
                 completion:^(BOOL finished){
                     [newViewController.view removeFromSuperview]; // remove from temp super view
                     [currentViewController presentViewController:newViewController animated:NO completion:NULL]; // present VC
                 }];
}

1 个答案:

答案 0 :(得分:1)

animations:^{
    newViewController.view.transform = CGAffineTransformMakeScale(1.0, 100.0);
    newViewController.view.center = originalCenter;
}

看起来你没有动画当前视图控制器的视图。我也不确定你为什么要设置新视图控制器视图的转换。我希望你的代码看起来像这样:

CGPoint originalCenter = currentViewController.view.center;
CGPoint newCurrentVCCenter = CGPointMake(currentViewController.view.center.x - screenWidth, currentViewController.center.y);
[UIView animateWithDuration:1.9
                  delay:0.0
                options:UIViewAnimationOptionCurveEaseInOut
animations:^{
    currentViewController.center = newCurrentVCCenter;
    newViewController.view.center = originalCenter;
}
completion:^(BOOL finished){
     // clean up here
}];

换句话说,您正在移动currentViewController.viewnewViewController.view,以便当前视图和新视图同时向左移动相同数量。