iPhone 向左卷曲和向右卷曲过渡 [英] iPhone Curl Left and Curl Right transitions

查看:25
本文介绍了iPhone 向左卷曲和向右卷曲过渡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种在 iPhone 上进行 UIViewAnimationTransitionCurlUpUIViewAnimationTransitionCurlDown 过渡的方法,但不是从上到下,而是从左到右(或上)/bottom 横向模式).我已经在互联网上多次看到这个问题,但没有人能得到答案.不过我觉得这是可行的.

I am looking for a way to do a UIViewAnimationTransitionCurlUp or UIViewAnimationTransitionCurlDown transition on the iPhone but instead of top to bottom, do it from the left to right (or top/bottom in landscape mode). I've seen this asked aroud the internet a few times but none sems to get an answer. However I feel this is doable.

我曾尝试更改 View 的变换和 view.layer 的变换,但这并没有影响过渡.由于当设备改变方向时过渡会发生变化,我认为有一种方法可以欺骗设备在纵向模式下使用横向过渡,反之亦然?

I have tried changing the View's transform and the view.layer's transform but that didn't affect the transition. Since the transition changes when the device changes orientation I presume there is a way to fool the device to use the landscape transition in portrait mode and vice versa?

推荐答案

我实际上是通过改变 UIViewController 的方向来实现这种效果的.奇怪的是,当我的控制器不起作用时,我将控制器嵌套在另一个控制器中,但是当我将他设置为直接视图控制器时,它起作用了.

I actually managed to achieve this effect by changing the orientation of my UIViewController. The strange thing is, I had my controller nesten in another one when it wasn't working, but when I set him as the immediate view controller, it worked.

代码:

在 UIViewController 中,它是我的应用程序委托中的主视图控制器,并且只允许横向(如您在下面的第二个方法中看到的),我有以下内容:

In a UIViewController that is the main view controller in my app delegate and only allows landscape orientation (as you see in the 2nd method below) I have the following:

-(void)goToPage:(int)page flipUp:(BOOL)flipUp {

     //do stuff...

     // start the animated transition
     [UIView beginAnimations:@"page transition" context:nil];
     [UIView setAnimationDuration:1.0];
     [UIView setAnimationTransition:flipUp ? UIViewAnimationTransitionCurlUp : UIViewAnimationTransitionCurlDown forView:self.view cache:YES];

     //insert your new subview
     //[self.view insertSubview:currentPage.view atIndex:self.view.subviews.count];

      // commit the transition animation
      [UIView commitAnimations];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
     return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

这篇关于iPhone 向左卷曲和向右卷曲过渡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆