gpt4 book ai didi

ios - 使用淡入动画呈现模态视图

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

我模态地呈现了一个登录屏幕,如下所示。如果我不对,请纠正我。

   UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *ivc = [storyboard instantiateViewControllerWithIdentifier:@"login"];//LOOK AT NEXT LINE
[self presentViewController:ivc animated:YES completion:nil];

确实出现了登录屏幕,但动画是向上滑动的。我更喜欢淡入淡出我们的动画。我该怎么做?

最佳答案

只需为 viewController 设置 modalTransitionStyle 属性。 ( Documentation )

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *ivc = [storyboard instantiateViewControllerWithIdentifier:@"login"];
[ivc setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
[self presentViewController:ivc animated:YES completion:nil];

在 Swift 中:

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let viewController = storyboard.instantiateViewController(withIdentifier: "login")
viewController.modalTransitionStyle = .crossDissolve
present(viewController, animated: true, completion: nil)

关于ios - 使用淡入动画呈现模态视图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30996195/

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