好久不见~~ iOS开发动画(Animation)总结

UIView的,翻转、旋转,偏移,翻页,缩放,取反的动画效果


翻转的动画
   
  1. //开始动画  
  2.    [UIView beginAnimations:@"doflip" context:nil];  
  3.    //设置时常  
  4.    [UIView setAnimationDuration:1];  
  5.    //设置动画淡入淡出  
  6.    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];  
  7.    //设置代理  
  8.    [UIView setAnimationDelegate:self];  
  9.    //设置翻转方向  
  10.    [UIView setAnimationTransition:  
  11.    UIViewAnimationTransitionFlipFromLeft  forView:manImageView cache:YES];  
  12.    //动画结束  
  13.    [UIView commitAnimations];  




旋转动画
  1. //创建一个CGAffineTransform  transform对象  
  2. CGAffineTransform  transform;   
  3. //设置旋转度数  
  4. transform = CGAffineTransformRotate(manImageView.transform,M_PI/6.0);  
  5. //动画开始  
  6. [UIView beginAnimations:@"rotate" context:nil ];  
  7. //动画时常  
  8. [UIView setAnimationDuration:2];  
  9. //添加代理  
  10. [UIView setAnimationDelegate:self];  
  11. //获取transform的值  
  12. [manImageView setTransform:transform];  
  13. //关闭动画  
  14. [UIView commitAnimations];  





偏移动画

    [UIView beginAnimations:@"move" context:nil];

    [UIView setAnimationDuration:2];

    [UIView setAnimationDelegate:self];

    //改变它的frame的x,y的值

    manImageView.frame=CGRectMake(100,100, 120,100);

    [UIView commitAnimations];


翻页动画

  

  1. [UIView beginAnimations:@"curlUp" context:nil];  
  2.   [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];//指定动画曲线类型,该枚举是默认的,线性的是匀速的  
  3.   //设置动画时常  
  4.   [UIView setAnimationDuration:1];  
  5.   [UIView setAnimationDelegate:self];  
  6.    //设置翻页的方向  
  7.   [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:manImageView cache:YES];  
  8.   //关闭动画  
  9.   [UIView commitAnimations];  



缩放动画

 

  1. CGAffineTransform  transform;  
  2. transform = CGAffineTransformScale(manImageView.transform,1.2,1.2);  
  3. [UIView beginAnimations:@"scale" context:nil];  
  4. [UIView setAnimationDuration:2];  
  5. [UIView setAnimationDelegate:self];  
  6. [manImageView setTransform:transform];  
  7. [UIView commitAnimations];  



取反的动画效果是根据当前的动画取他的相反的动画

   

    1. CGAffineTransform transform;  
    2.    transform=CGAffineTransformInvert(manImageView.transform);  
    3.      
    4.    [UIView beginAnimations:@"Invert" context:nil];  
    5.    [UIView setAnimationDuration:2];//动画时常  
    6.    [UIView setAnimationDelegate:self];  
    7.    [manImageView setTransform:transform];//获取改变后的view的transform  
    8.    [UIView commitAnimations];//关闭动画 
原文地址:https://www.cnblogs.com/duyuiOS/p/5231491.html