1

我在主视图中添加了 4 个 UIView 类型的子视图。我想用平滑的翻转动画翻转这些视图。我已经尝试过但无法成功完成它。这是我使用的代码。

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:signUpView cache:YES];
[UIView commitAnimations];

它翻转一半并立即显示另一个视图。让我知道怎么做?

4

3 回答 3

3

在开始时,我将我的 firstView 添加到 containerView

[self.containerView addSubview:firstView];

在那之后你需要添加你的翻转过渡

[UIView transitionWithView:self.containerView
                  duration:1
                   options:UIViewAnimationOptionTransitionFlipFromRight
                animations:^{ [firstView removeFromSuperview]; [self.containerView addSubview:secondView]; }
                completion:NULL];
于 2013-06-04T06:41:37.017 回答
3

你甚至可以试试这个

CATransition *animation = [CATransition animation];
    animation.delegate = self;
    animation.duration = 1;
    animation.timingFunction = UIViewAnimationCurveEaseInOut;
    animation.fillMode = kCAFillModeForwards;
    animation.endProgress = 1;
    animation.removedOnCompletion = NO;
    animation.type = @"oglFlip";

    [yourView.layer addAnimation:animation forKey:@"animation"];

如果您愿意,可以使用更多动画类型:

animation.type = @"cube";
animation.type = @"suckEffect";
animation.type = @"suckEffect";
animation.type = @"pageCurl";
animation.type = @"pageUnCurl";
animation.type = @"cameraIrisHollowOpen ";
animation.type = @"cameraIrisHollowClose ";
于 2013-06-04T07:03:14.157 回答
-1

尝试分别翻转每个视图。也许像这样

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:signInView cache:YES];
[UIView commitAnimations];
//
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:signUpView cache:YES];
[signInView setHidden:YES];//or you can use remove subview
[signUpView setHidden:NO];// you can use addsubview
[UIView commitAnimations];
于 2013-06-04T06:56:09.877 回答