gpt4 book ai didi

iphone - 解雇ModalViewController与过渡: left to right

转载 作者:行者123 更新时间:2023-12-03 18:21:13 25 4
gpt4 key购买 nike

我使用了一个很好的方法来关闭我的模态视图 Controller :

[self dismissModalViewControllerWithTransition:2];

它使幻灯片从左到右过渡,就像导航 Controller 弹出 View 一样。

由于该方法是非公开方法,苹果不会接受。如何在我的代码中编写这种动画(从左到右滑动以关闭模态视图,从右到左滑动以呈现模态视图)?

提前致谢

最佳答案

我已经接受了 Safecase 的答案,但我想在这里发布我的最终解决方案:

1)为了呈现一个具有从右到左转换的模态视图 Controller ,我编写了以下方法:

-(void) presentModalView:(UIViewController *)controller {
CATransition *transition = [CATransition animation];
transition.duration = 0.35;
transition.timingFunction =
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionMoveIn;
transition.subtype = kCATransitionFromRight;

// NSLog(@"%s: self.view.window=%@", _func_, self.view.window);
UIView *containerView = self.view.window;
[containerView.layer addAnimation:transition forKey:nil];
[self presentModalViewController:controller animated:NO];
}

2) 要通过从左到右的幻灯片过渡来关闭模态视图:

-(void) dismissMe {
CATransition *transition = [CATransition animation];
transition.duration = 0.35;
transition.timingFunction =
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionMoveIn;
transition.subtype = kCATransitionFromLeft;

// NSLog(@"%s: controller.view.window=%@", _func_, controller.view.window);
UIView *containerView = self.view.window;
[containerView.layer addAnimation:transition forKey:nil];

[self dismissModalViewControllerAnimated:NO];
}

谢谢大家!

关于iphone - 解雇ModalViewController与过渡: left to right,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11412467/

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