我正在尝试使用 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
发布评论
评论(1)
您是否尝试过使用
UIViewAnimationTransitionCurlDown
?它是UIViewAnimationTransitionCurlUp
的相反方向。Have you tried using
UIViewAnimationTransitionCurlDown
? It is the reverse direction ofUIViewAnimationTransitionCurlUp
.