gpt4 book ai didi

ios - 如何自定义模态视图 Controller 呈现动画?

转载 作者:IT王子 更新时间:2023-10-29 07:56:51 27 4
gpt4 key购买 nike

我不想设置 uiviewcontroller 的 modalTransitionStyle,而是想添加一个 CAAnimation(或其他东西)。此代码可以在 navigationController 中执行自定义动画

CATransition* transition = [CATransition animation];
transition.duration = 0.4;
transition.type = kCATransitionFade;
transition.subtype = kCATransitionFromBottom;
[self.navigationController.view.layer addAnimation:transition forKey:kCATransition];
[self.navigationController pushViewController:adjustViewController animated:NO];

如何将它实现到模态视图 Controller ?

最佳答案

您只需要将过渡添加到窗口层,并呈现您的 Controller 而不是推送它:

     CATransition* transition = [CATransition animation];
transition.duration = 1;
transition.type = kCATransitionFade;
transition.subtype = kCATransitionFromBottom;
[self.view.window.layer addAnimation:transition forKey:kCATransition];
[self presentViewController:adjustViewController animated:NO completion:nil];

关于ios - 如何自定义模态视图 Controller 呈现动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19931710/

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