1

I have 4 subviews of type UIView which is added in main view. I want to flip these views with smooth flip animation. I have tried but not able to successfully able to complete it. here is the code I have used.

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

it flips the half and promptly displays the other view. let me know how to this?

  • http://stackoverflow.com/questions/17272179/how-can-i-create-vertical-flip-view-animation-in-ios/17342105#17342105 – Pradeep Jul 03 '13 at 08:04

3 Answers3

3

at start im adding my firstView to containerView

[self.containerView addSubview:firstView];

after that where you need to add you flip transition

[UIView transitionWithView:self.containerView
                  duration:1
                   options:UIViewAnimationOptionTransitionFlipFromRight
                animations:^{ [firstView removeFromSuperview]; [self.containerView addSubview:secondView]; }
                completion:NULL];
p.balmasov
  • 357
  • 1
  • 16
3

You can even try this

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"];

Some more animation types if you want :

animation.type = @"cube";
animation.type = @"suckEffect";
animation.type = @"suckEffect";
animation.type = @"pageCurl";
animation.type = @"pageUnCurl";
animation.type = @"cameraIrisHollowOpen ";
animation.type = @"cameraIrisHollowClose ";
Prashant Nikam
  • 2,253
  • 4
  • 17
  • 29
-1

try flipping each view separately. Maybe like this

[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];
Manish Agrawal
  • 10,958
  • 6
  • 44
  • 76
  • The `beginAnimations:` `commitAnimations:` method of UIView animation has been deprecated since iOS4, the recommendation is to use the block based animation methods instead. – Abizern Jun 04 '13 at 10:00