iOS-模态视图动画

ios视图切换的动画效果

 

方法1.把下面的这段代码加到viewController或者view出现的时候就OK

 self.view.transform=CGAffineTransformMakeScale(0.01f, 0.01f);//先让要显示的view最小,0.01f是指比例
    
    [UIView beginAnimations:nil context:UIGraphicsGetCurrentContext()];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:0.5f];//动画时间,自己看着办
    self.view.transform = CGAffineTransformMakeScale(1.0f, 1.0f);//将要显示的view按照正常比例显示出来
    //[UIView commitModalAnimations];
    [UIView commitAnimations];

 

 

方法2.当push一个viewController的时候的添加效果

把下面的代码加到push的方法里面就OK

    CATransition *myTranstiton = [CATransition animation];
    myTranstiton.duration = 0.5;
    myTranstiton.type = kCATransitionFade;    
    //myTranstiton.subtype = kCATransitionFromTop;    
    [self.view.superview.layer  addAnimation:myTranstiton forKey:nil ];    
    MainViewController * _mainViewController=[[MainViewController alloc] init]; 
    [self presentModalViewController:_mainViewController animated:NO];

 

原文地址:https://www.cnblogs.com/linxiu-0925/p/5086019.html