OStack程序员社区-中国程序员成长平台

标题: ios - 在 View Controller 之间转换时自定义动画 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 10:58
标题: ios - 在 View Controller 之间转换时自定义动画

我想像这样在 View Controller 之间创建过渡。 https://www.dropbox.com/s/qatwqaq2mowocsg/Transitions%20Controller.gif?dl=0

我已使用以下代码创建过渡,但无法实现以下结果。

self.settings = [self.storyboard instantiateViewControllerWithIdentifier"settings"];
CATransition* transition = [CATransition animation];

transition.duration = 0.4;
transition.type = kCATransitionPush;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault];
transition.subtype=kCATransitionFromRight;


[[self navigationController].view.layer addAnimation:transition forKey:kCATransition];
[[self navigationController] pushViewController:self.settings animated:NO];



Best Answer-推荐答案


你可以试试这个代码:

self.settings = [self.storyboard instantiateViewControllerWithIdentifier"settings"];

[UIView beginAnimations"View Flip" context:nil];
[UIView setAnimationDuration:0.80];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

[UIView setAnimationTransition:
 UIViewAnimationTransitionFlipFromRight
                       forView:self.navigationController.view cache:NO];


[self.navigationController pushViewController:self.settings animated:YES];
[UIView commitAnimations];

关于ios - 在 View Controller 之间转换时自定义动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32710102/






欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) Powered by Discuz! X3.4