iPhone Curl Left和Curl Right过渡

Dim*_*ris 9 iphone curl transition uiview cgaffinetransform

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

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

flu*_*uXa 9

通过使用容器视图,可以在四个方向中的任何一个方向上进行卷曲.将容器视图的转换设置为您想要的角度,然后通过将视图添加到容器视图来进行卷曲,而不是应用程序的主视图中没有转换的框架:

NSView* parent = viewController.view; // the main view
NSView* containerView = [[[UIView alloc] initWithFrame:parent.bounds] autorelease];
containerView.transform = CGAffineTransformMakeRotation(<your angle here, should probably be M_PI_2 * some integer>);
[parent addSubview:containerView]; 

[UIView beginAnimations:nil context:nil];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:containerView cache:YES];
[containerView addSubview:view];
[UIView commitAnimations];
Run Code Online (Sandbox Code Playgroud)


Dim*_*ris 4

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

执行此操作的代码:

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

-(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);
}
Run Code Online (Sandbox Code Playgroud)