两个view之间的翻转转场动画章

self.cellBackView
self.mulCarNumView
两个view之间的转场动画 self.cellBackView -->self.mulCarNumView

//方法一

    UIView *fromView, *toView;
    if (isMulCar)
    {
        fromView = self.mulCarNumView;
        toView = self.cellBackView;
    }
    else
    {
        fromView = self.cellBackView;
        toView = self.mulCarNumView;
    }
    UIViewAnimationOptions  options =   UIViewAnimationOptionShowHideTransitionViews|UIViewAnimationOptionTransitionFlipFromLeft;

    [UIView transitionFromView:fromView
                        toView:toView
                      duration:1.0
                       options:options
                    completion:^(BOOL finished) {
                        // animation completed
                        //抖动
                        CAKeyframeAnimation *animation = [[CAKeyframeAnimation alloc] init];
                        [animation setDelegate:self];
                        animation.values = @[@(M_PI/64),@(-M_PI/64),@(M_PI/64),@(0)];
                        animation.duration = 0.5;
                        [animation setKeyPath:@"transform.rotation"];
                        animation.removedOnCompletion = YES;
                        animation.fillMode = kCAFillModeForwards;
                        [self.mulCarNumView.layer addAnimation:animation forKey:@"shake"];
                    }];
    

//方法二

 UIViewAnimationTransition  options =    UIViewAnimationTransitionFlipFromLeft;

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:1];
    [UIView setAnimationTransition:options forView:self.mulCarNumView cache:NO];
    [UIView setAnimationDelegate:self];
    [UIView commitAnimations];
    
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:1];
    [UIView setAnimationTransition:options forView:self.cellBackView cache:NO];
    [UIView setAnimationDelegate:self];
    [UIView commitAnimations];

你可能感兴趣的:(两个view之间的翻转转场动画章)