首页 技术 正文
技术 2022年11月20日
0 收藏 589 点赞 3,732 浏览 2418 个字

详解IPhone动画效果类型及实现方法是本文要介绍的内容,主要介绍了iphone动画的实现方法,不多说,我们一起来看内容。

实现iphone漂亮的动画效果主要有两种方法,一种是UIView层面的,一种是使用CATransition进行更低层次的控制.

1、UIView

  1. CGContextRef context = UIGraphicsGetCurrentContext();
  2. [UIView beginAnimations:nil context:context];
  3. [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
  4. [UIView setAnimationDelegate:self];
  5. [UIView setAnimationDuration:1.0];          //动画持续的时间
  6. //这里添加你对UIView所做改变的代码
  7. //[UIView setAnimationDidStopSelector:@selector(animationFinished:)];   //动画停止后,执行某个方法
  8. [UIView commitAnimations];

2、UIView(使用Cocoa Touch)

  1. CGContextRef context = UIGraphicsGetCurrentContext();
  2. [UIView beginAnimations:nil context:context];
  3. [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
  4. [UIView setAnimationDuration:1.0];
  5. // Cocoa Touch
  6. [UIView setAnimationTransition: UIViewAnimationTransitionCurlUp forView:myView cache:YES];
  7. [UIView setAnimationDelegate:self];
  8. //[UIView setAnimationDidStopSelector:@selector(animationFinished:)]; //动画停止后,执行某个方法
  9. [UIView commitAnimations];
  10. 动画方式(UIViewAnimationTransition):
  11. UIViewAnimationTransitionFlipFromLeft              //从左向右翻转
  12. UIViewAnimationTransitionFlipFromRight             //从右向左翻转
  13. UIViewAnimationTransitionCurlUp                    //从下向上翻页
  14. UIViewAnimationTransitionCurlDown                  //从上向下翻页

3、CATransition

  1. CATransition *animation = [CATransition animation];
  2. animation.delegate = self;
  3. animation.duration = 1.0f;       //动画执行时间
  4. animation.timingFunction = UIViewAnimationCurveEaseInOut;
  5. animation.type = kCATransitionFade;
  6. animation.subtype = kCATransitionFromRight;
  7. // 这里添加你对UIView所做改变的代码
  8. [[myView layer] addAnimation:animation forKey:@"animation"];

setType:有四种类型:

  1. kCATransitionFade                   //交叉淡化过渡
  2. kCATransitionMoveIn               //移动覆盖原图
  3. kCATransitionPush                    //新视图将旧视图推出去
  4. kCATransitionReveal                //底部显出来

setSubtype:有四种类型:

  1. kCATransitionFromRight;
  2. kCATransitionFromLeft(默认值)
  3. kCATransitionFromTop;
  4. kCATransitionFromBottom
  5. 注:kCATransitionFade 不支持Subtype

4、CATransition(只使用setType,参数是NSString)

  1. CATransition *animation = [CATransition animation];
  2. animation.delegate = self;
  3. animation.duration = 1.0f;   //动画执行时间
  4. animation.timingFunction = UIViewAnimationCurveEaseInOut;
  5. animation.type = @"suckEffect";// 这里添加你对UIView所做改变的代码
  6. [[myView layer] addAnimation:animation forKey:@"animation"];

可以用的效果主要有:

  1. pageCurl     //向上翻一页
  2. pageUnCurl   //向下翻一页
  3. rippleEffect   //滴水效果
  4. suckEffect     //收缩效果,如一块布被抽走
  5. cube       //立方体效果
  6. oglFlip      //上下翻转效果

小结:详解IPhone动画效果类型及实现方法的内容介绍完了,希望本文对你有所帮助

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,117
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,590
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,435
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,206
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,842
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,927