UIVIew Flip Vertical Animation

后端 未结 1 891
情深已故
情深已故 2020-12-17 05:04

Given:

[UIView beginAnimations:nil context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut]; 
[UIView setAnimationDuration:.5];
[UIView setAnimat         


        
相关标签:
1条回答
  • 2020-12-17 05:43

    I've also needed flip from bottom animation. I've compiled couple solutions and this works for me

    - (CATransform3D) makeRotationAndPerspectiveTransform:(CGFloat) angle {
        CATransform3D transform = CATransform3DMakeRotation(angle, 1.0f, 0.0f, 0.0f);
        transform.m34 = 1.0 / -500;
        return transform;
    }
    
    - (void) flipFromBottom {
    
        //setup firstView to be visible
        view1.layer.transform =  CATransform3DMakeRotation(0, 1.0f, 0.0f, 0.0f);
        view1.hidden = NO;
    
        // setup secondView to be partialy rotated and invisible
        view2.layer.transform = [self makeRotationAndPerspectiveTransform:M_PI/2];
        view2.hidden = YES;
    
        // making sure that both views have the same position
        view2.frame = view1.frame;
    
        CFTimeInterval duration =  2.0;
    
        [UIView animateWithDuration:duration/2 
                              delay:0
                            options:UIViewAnimationCurveEaseIn
                         animations:^{
                             view1.layer.transform = [self makeRotationAndPerspectiveTransform:-M_PI / 2];
                         } 
                         completion:^(BOOL finished){
                             view1.hidden = YES;
                             view2.hidden = NO;
                             [UIView animateWithDuration:duration /2 
                                                   delay:0
                                                 options:UIViewAnimationCurveEaseOut
                                              animations:^{
                                 view2.layer.transform =  CATransform3DMakeRotation(0.0f, 1.0f, 0.0f, 0.0f);
                                              }
                                              completion:NULL];
                         }];
    }
    
    0 讨论(0)
提交回复
热议问题