我想要做的有点类似于引用此SO question的MLB app,除了网格之外,我使用基于UIScrollView的SwipeView。
这个问题的答案并不令人满意。好像你不应该手动编写整个动画序列。
有没有办法通过简单地使用presentViewController和内置的翻转过渡效果来做到这一点?
答案 0 :(得分:8)
Swift iOS 8
如果您想通过View控制器翻转视图控制器
// Create a new view controller and pass suitable data.
let storyboard = UIStoryboard(name: "Main", bundle: nil);
// assign page view content loader
let fBSignRegisterViewController = storyboard.instantiateViewControllerWithIdentifier("FBSignRegisterViewController")
as? FBSignRegisterViewController;
fBSignRegisterViewController?.modalTransitionStyle = UIModalTransitionStyle.FlipHorizontal
self.presentViewController(fBSignRegisterViewController!, animated: true, completion: nil)
答案 1 :(得分:2)
你是对的,UIView上有一个内置方法来处理这个问题:
[UIView transitionWithView:containerView
duration:0.2
options:UIViewAnimationOptionTransitionFlipFromLeft
animations:^{
[fromView removeFromSuperview];
[containerView addSubview:toView]; }
completion:NULL];
或者,使用viewControllers:
AboutViewController * vc = [[AboutViewController alloc] initWithNibName:@"AboutViewController" bundle:nil];
vc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:vc animated:YES];
答案 2 :(得分:0)
我认为您正在寻找的是一种名为transitionwithView的UIView方法。查看示例here。