UIViewAnimationTransitionCurlUp 从右到左横向(左和右)方向

发布于 2024-12-13 12:51:37 字数 1754 浏览 3 评论 0 原文

我正在尝试使用 UIViewAnimationTransitionCurlUp 在两个视图之间进行转换。 我的应用程序在横向(左和右)下运行,我需要从右到左的转换。 UIViewAnimationTransitionCurlUp 从下到上工作(而不是像我想要的从右到左)。 我的第一个版本是:

self.oneView = [[[UIImageView alloc] initWithFrame:frame] autorelease];
self.twoView = [[[UIImageView alloc] initWithFrame:frame] autorelease];
[self.view addSubview:self.oneView];

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
[self.oneView removeFromSuperview];
[self.view addSubview:twoView];
[UIView commitAnimations];

它在横向模式下工作,主页按钮位于右侧(根据需要从右到左从右上角开始转换)。 但是,当设备旋转到左侧的主页按钮时,卷曲效果是颠倒的:从左到右从左下角开始)。 动画似乎不知道设备方向。 我更改了代码以便使用中间容器视图(在 self.view 和

self.oneView/twoView):
self.containerView = [[[UIView alloc] initWithFrame:frame] autorelease];
self.oneView = [[[UIImageView alloc] initWithFrame:frame] autorelease];

self.twoView = [[[UIImageView alloc] initWithFrame:frame] autorelease];
[self.view addSubview:self.containerView];
[self.containerView addSubview:self.oneView]

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.containerView cache:YES];
[self.oneView removeFromSuperview];
[self.containerView addSubview:twoView];
[UIView commitAnimations];

Now 之间),它知道设备旋转并在横向方向上都能正常工作。 但它是从下到上工作的(从右下角开始),正如文档中所述。 但我希望它从右到左工作。 我还尝试使用视图的转换属性,例如:

self.containerView.transform = CGAffineTransformMakeRotation(-M_PI_2);
self.oneView.transform = CGAffineTransformMakeRotation(M_PI_2);

它没有帮助。 那么,一个问题是: 如何在横向模式(左和右)下使用过渡 UIViewAnimationTransitionCurlUp 在视图之间从右到左进行过渡? 感谢您的帮助! 亚历克斯

I'm trying to make a transition between two views with UIViewAnimationTransitionCurlUp.
My application works in landscape (left and right) and I need transition from right to left.
UIViewAnimationTransitionCurlUp works from down to up (and not from right to left as I want).
My first version was:

self.oneView = [[[UIImageView alloc] initWithFrame:frame] autorelease];
self.twoView = [[[UIImageView alloc] initWithFrame:frame] autorelease];
[self.view addSubview:self.oneView];

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
[self.oneView removeFromSuperview];
[self.view addSubview:twoView];
[UIView commitAnimations];

It worked in landscape with home button on the right (transition was from right to left started with right-upper corner as desired).
But when device was rotated to home button on the left, curl affect was upside down: from left to right started with left-buttom corner).
It seemed that animation wasn't aware of device orientation.
I changed a code in order to use intermediate container view (between self.view and

self.oneView/twoView):
self.containerView = [[[UIView alloc] initWithFrame:frame] autorelease];
self.oneView = [[[UIImageView alloc] initWithFrame:frame] autorelease];

self.twoView = [[[UIImageView alloc] initWithFrame:frame] autorelease];
[self.view addSubview:self.containerView];
[self.containerView addSubview:self.oneView]

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.containerView cache:YES];
[self.oneView removeFromSuperview];
[self.containerView addSubview:twoView];
[UIView commitAnimations];

Now it was aware of device rotation and worked correctly for both landscape orientation.
But it worked from down to up (started with right-bottom corner) as it described in docs.
But I want it to work from right to left.
I also tried to use transform property of views like:

self.containerView.transform = CGAffineTransformMakeRotation(-M_PI_2);
self.oneView.transform = CGAffineTransformMakeRotation(M_PI_2);

It didn't help.
So, a question is:
How to use transition UIViewAnimationTransitionCurlUp in landscape mode (both left and right) for transition between views from right to left?
Thanks for any help!
Alex

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你如我软肋 2024-12-20 12:51:37

您是否尝试过使用UIViewAnimationTransitionCurlDown?它是UIViewAnimationTransitionCurlUp的相反方向。

Have you tried using UIViewAnimationTransitionCurlDown? It is the reverse direction of UIViewAnimationTransitionCurlUp.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文