我已经尝试了一段时间来创建一个与封面垂直相反的自定义segue(创建一个从上到下的效果动画).我查看了其他问题,google和youtube但是无法让它工作.我是这是一个全新的课程等,所以任何步骤指南或视频的帮助都会很好.我相信这个URL正在尝试做类似于我想要的事情:
如果你们中的任何人都知道如何创建一个segue的顶部到底部版本的segue你可以帮助我吗?
好吧,你想要创建一个UIStoryBoardSegue的子类,就像演练向你展示的那样,但是在Storyboard类'.m文件(实现)中你需要以下代码作为你的 - (void)perform:方法 -
-(void)perform{
UIViewController *sourceViewController = (UIViewController *) self.sourceViewController;
UIViewController *destinationViewController = (UIViewController *) self.destinationViewController;
[sourceViewController.view addSubview:destinationViewController.view];
[destinationViewController.view setFrame:sourceViewController.view.window.frame];
[destinationViewController.view setTransform:CGAffineTransformMakeTranslation(0, -sourceViewController.view.frame.size.height)];
[destinationViewController.view setAlpha:1.0];
[UIView animateWithDuration:0.75
delay:0.0
options:UIViewAnimationOptionTransitionFlipFromTop
animations:^{
[destinationViewController.view setTransform:CGAffineTransformMakeTranslation(0, 0)];
[destinationViewController.view setAlpha:1.0];
}
completion:^(BOOL finished){
[destinationViewController.view removeFromSuperview];
[sourceViewController presentViewController:destinationViewController animated:NO completion:nil];
}];}
Run Code Online (Sandbox Code Playgroud)
希望这很有帮助.