iOS:如何翻转超过180度的UIView并查看背面?

时间:2013-12-04 21:43:23

标签: ios uiview 3d rotation uikit

是否可以翻转关于x或y轴的UIView,以便它完全翻转,你可以看到视图的“背面”?我认为UIKit基于OpenGL ES,因此存在使用双面三角形实现图层的问题......

1 个答案:

答案 0 :(得分:2)

要翻转到视图控制器:

viewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentViewController:viewController animated:YES completion:nil];

要摆脱它:

[self dismissViewControllerAnimated:YES completion:nil];

如果您只想翻转视图,可以将想要翻转的两个视图放在一个大小相同的未命名视图中,并链接IBOutlet UIView * newView,* oldView;视图并将新视图放在顶部

bool a = NO;

@implementation ViewController

- (IBAction)flip:(id)sender 
{
    if (a == NO) {
        [UIView transitionFromView:oldView toView:newView  
                  duration:1.0 
                  options:UIViewAnimationOptionTransitionFlipFromLeft 
                  completion:NULL];
        a = YES; // a = !a;
    }
    else {
        [UIView transitionFromView:newView toView:oldView  
                  duration:1.0 
                  options:UIViewAnimationOptionTransitionFlipFromLeft 
                  completion:NULL];
        a = NO; // a = !a;
    }
}

来源:How to flip an individual UIView (without flipping the parent view)


您可以检查这个很棒的自定义控制器: