我对两个情节提要控制器之间的过渡动画有问题。我在故事板上有一个带有两个视图控制器的singleView项目。
现在我要制作一个自定义过渡动画:
我已经UIStoryboardSegue
上课了。
但是我该怎么写呢-(void)perform{}
?
非常感谢,
乔纳斯
对于这种简单的搜索,您可以尝试执行以下操作:
- (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];
}];
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句