美文网首页
两个view之间的翻转转场动画章

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

作者: kenewang | 来源:发表于2016-07-05 16:38 被阅读124次

    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之间的翻转转场动画章

          本文链接:https://www.haomeiwen.com/subject/dpwhjttx.html