gpt4 book ai didi

iPhone 开发者 : how to control the view transition animation?

转载 作者:行者123 更新时间:2023-11-29 04:35:06 28 4
gpt4 key购买 nike

我正在使用这样的代码来呈现一个新的 View ,我不知道它好不好。目前默认动画是从下往上显示 View ,但我希望它从右到左(飞入)动画,是否可以更改默认动画类型以及如何更改?谢谢。

[self presentModalViewController:navController animated:animated];

最佳答案

您可以像这样禁用上滑动画:

[self presentModalViewController:navController animated:NO];

然后您可以提供自己的动画代码:

navController.view.frame = CGRectMake(320, 0, navController.view.frame.size.width, navController.view.frame.size.height);

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
navController.view.frame = CGRectMake(0, 0, navController.view.frame.size.width, navController.view.frame.size.height);
[UIView commitAnimations];

此示例为您提供了从右侧“飞入”的平滑速度曲线。

另一种方法是使用导航 Controller 从右侧内置的滑入式:

[self.navigationController pushViewController:navController animated:YES];

在这个中,您的顶级 View Controller 需要是 UINavigationController,并且它的根 Controller 需要是您的 View Controller 。然后你可以推送其他 View Controller 。

关于iPhone 开发者 : how to control the view transition animation?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11170345/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com