zoukankan      html  css  js  c++  java
  • ios 学习总结之动画(转)

    转自:http://blog.sina.com.cn/s/blog_a85effc301012wu4.html
    UIView的,翻转、旋转,偏移,翻页,缩放,取反的动画效果
     
    翻转的动画
    //开始动画

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

    //设置时常

        [UIView setAnimationDuration:1];

    //设置动画淡入淡出

        [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

    //设置代理

        [UIView setAnimationDelegate:self];

    //设置翻转方向

        [UIView setAnimationTransition:

       UIViewAnimationTransitionFlipFromLeft  forView:manImageView cache:YES];

    //动画结束

        [UIView commitAnimations];

    旋转动画
     
    创建一个CGAffineTransform  transform对象

        CGAffineTransform  transform; 

    //设置旋转度数

        transform = CGAffineTransformRotate(manImageView.transform,M_PI/6.0);

    //动画开始

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

    //动画时常

        [UIView setAnimationDuration:2];

    //添加代理

        [UIView setAnimationDelegate:self];

    //获取transform的值

        [manImageView setTransform:transform];

    //关闭动画

        [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];

    翻页动画

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

        [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];//指定动画曲线类型,该枚举是默认的,线性的是匀速的

        //设置动画时常

        [UIView setAnimationDuration:1];

         [UIView setAnimationDelegate:self];

        //设置翻页的方向

        [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:manImageView cache:YES];

        //关闭动画

        [UIView commitAnimations];

    缩放动画

    CGAffineTransform  transform;

        transform = CGAffineTransformScale(manImageView.transform,1.2,1.2);

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

        [UIView setAnimationDuration:2];

        [UIView setAnimationDelegate:self];

        [manImageView setTransform:transform];

        [UIView commitAnimations];

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

    CGAffineTransform transform;

        transform=CGAffineTransformInvert(manImageView.transform);

        

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

        [UIView setAnimationDuration:2];//动画时常

        [UIView setAnimationDelegate:self];

        [manImageView setTransform:transform];//获取改变后的viewtransform

        [UIView commitAnimations];//关闭动画

  • 相关阅读:
    使用sourcetree 出现 For user git on host github.com 解决方案
    iOS App Store下载的付费软件 重新签名后 安装到未越狱的手机上
    Swift 入门之简单语法(一)
    [转]C语言指针 之 结构体指针
    Xcode 菜单详解 [转载自用]
    C语言笔记-字符串+转义符(写起来想砸键盘)
    C语言笔记-getchar等蛋疼设定 [可能已解决]
    C语言笔记-枚举类型
    C语言笔记-数据类型长度
    C语言笔记-函数-存储期和作用域
  • 原文地址:https://www.cnblogs.com/huanglong/p/3217095.html
Copyright © 2011-2022 走看看