iOS View动画

看我就会动画了:链接: https://pan.baidu.com/s/1dE9St4d 密码: bb4c
翻转动画

    //开始动画
    [UIView beginAnimations:nil context:nil];
    //设置时常
    [UIView setAnimationDuration:1];
    //设置动画淡入淡出
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    //设置代理
    [UIView setAnimationDelegate:self];
    //设置翻转方向
    [UIView setAnimationTransition: UIViewAnimationTransitionCurlUp forView:self.myView cache:YES];
    //动画结束
    //当动画执行结束,执行animationFinished方法
    [UIView setAnimationDidStopSelector:@selector(animationFinished:)];
    [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];//获取改变后的view的transform
[UIView commitAnimations];//关闭动画
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 174,539评论 25 709
  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 12,294评论 4 61
  • 一、这本书在谈些什么? 本书写作对象:对时间管理存在困惑,希望通过时间管理、个人管理实现自我提升的人。(这么说其实...
    五荷阅读 381评论 0 2
  • 一直以为,生活应该是不被受限的。 关于画画。 额,原谅我一直没有绘画天赋,却固执的想要表现自己。在经历无数次的思想...
    共央阅读 260评论 2 4
  • 最近,父亲有了变化:在与我有关的事情上,他会提前向我确认;在情绪激动,嗓门太大时,他会及时向我解释他的想法;我也有...
    寻一之旅阅读 782评论 15 24