gpt4 book ai didi

ios - 如何从右到左关闭模态 ViewController?

转载 作者:可可西里 更新时间:2023-11-01 04:09:37 26 4
gpt4 key购买 nike

在 Objective-C 中,我想从右到左关闭模态 ViewController。

现在我可以在模态上从左向右移动。但是我不知道如何像推屏转换一样从左到右关闭这个模态 VC。

这是从 a-ViewController 移动到 b-ViewController 的代码。

bViewController *nextVC = [[bViewController alloc] initWithNibName:nil bundle:nil];

CATransition *transition = [CATransition animation];
transition.duration = 0.5;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
transition.type = kCATransitionPush ;
[transition setSubtype:kCATransitionFromLeft];
[[nextVC.view layer] addAnimation:transition forKey:@"TransitionTest"];
//[self presentViewController:nextVC animated:YES completion:nil];
//if it's possible, I want to use upside's cord.(don't addSubView) but I don't know how to do it)
[self.view addSubview:nextVC.view] ;

最佳答案

objective-C

CATransition *transition = [CATransition animation];
transition.duration = 0.4;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromRight;
[self.view.window.layer addAnimation:transition forKey:nil];
[self dismissViewControllerAnimated:NO completion:nil];

swift 5

let transition = CATransition()
transition.duration = 0.5
transition.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeInEaseOut)
transition.type = CATransitionType.push
transition.subtype = CATransitionSubtype.fromRight
self.view.window!.layer.add(transition, forKey: nil)
self.dismiss(animated: false, completion: nil)

关于ios - 如何从右到左关闭模态 ViewController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35694091/

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