iOS开发动画总结(Animation)

本文详细介绍了UIView中的多种动画效果实现方法,包括翻转、旋转、偏移、翻页、缩放及取反等动画,并提供了具体的代码示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

UIView的,翻转、旋转,偏移,翻页,缩放,取反的动画效果
翻转的动画
     
[objc]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  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];  
  14. 旋转动画
    [objc]  view plain  copy
      在CODE上查看代码片 派生到我的代码片
    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];


    翻页动画

      

    [objc]  view plain  copy
      在CODE上查看代码片 派生到我的代码片
    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];  



    缩放动画

    [objc]  view plain  copy
      在CODE上查看代码片 派生到我的代码片
    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];  



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

       

    [objc]  view plain  copy
      在CODE上查看代码片 派生到我的代码片
    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];//关闭动画  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值