1.过渡动画 CATransition

   CATransition *animation = [CATransition animation];

    [animation setDuration:1.0];

    [animation setType:kCATransitionFade];

    [animation setSubtype:kCATransitionFromLeft];

    [_imgPic.layer addAnimation:animation forKey:nil];

说明:

  (1).Duration 延迟

  (2).Type

    kCATransitionFade      // 交叉淡化过渡(不支持过渡方向)

    kCATransitionMoveIn   // 新视图移到旧视图上面

    kCATransitionPush    // 新视图把旧视图推出去

      kCATransitionReveal   // 将旧视图移开,显示下面的新视图

    cube     // 立方体翻滚效果

    oglFlip  // 上下左右翻转效果

    suckEffect   // 收缩效果,如一块布被抽走(不支持过渡方向)

    rippleEffect // 滴水效果(不支持过渡方向)

    pageCurl     // 向上翻页效果

    pageUnCurl   // 向下翻页效果

    cameraIrisHollowOpen   // 相机镜头打开效果(不支持过渡方向)

    cameraIrisHollowClose  // 相机镜头关上效果(不支持过渡方向)

2.路径动画  CAKeyframeAnimation

    CAKeyframeAnimation *ani=[CAKeyframeAnimation animation];
CGMutablePathRef aPath=CGPathCreateMutable(); CGPathMoveToPoint(aPath, nil, , );
CGPathAddCurveToPoint(aPath, nil,
, ,
, ,
, ); ani.path=aPath;
ani.duration=;
ani.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
ani.rotationMode=@"autoReverse";
[redView.layer addAnimation:ani forKey:@"position"];

//特殊曲线 贝塞尔曲线

//贝塞尔曲线路径
UIBezierPath *movePath = [UIBezierPath bezierPath];
[movePath moveToPoint:CGPointMake(0.0, 0.0)];
[movePath addQuadCurveToPoint:CGPointMake(self.view.frame.size.width/2.0, self.view.frame.size.height/2.0) controlPoint:CGPointMake(self.view.frame.size.width, self.view.frame.size.height)];

说明:(1).moveToPoint :动画起始位置

   (2).轨迹

   - (void)addQuadCurveToPoint:(CGPoint)endPoint controlPoint:(CGPoint)controlPoint;

   //endPoint 完成位置  controllerPoint  轨迹中的位置

3.基本类型  CABasicAnimation 事例

  //背景色动画
CABasicAnimation *animation=[CABasicAnimation animation];
//设置颜色
animation.toValue=(id)[UIColor blueColor].CGColor;
//动画时间
animation.duration=;
//是否反转变为原来的属性值
animation.autoreverses=YES;
//把animation添加到图层的layer中,便可以播放动画了。forKey指定要应用此动画的属性
[self.view.layer addAnimation:animation forKey:@"backgroundColor"]; //缩放动画
CABasicAnimation *scaleAnim = [CABasicAnimation animationWithKeyPath:@"transform"];
scaleAnim.fromValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.1, 0.1, 1.0)];
scaleAnim.toValue = [NSValue valueWithCATransform3D:CATransform3DIdentity];
scaleAnim.removedOnCompletion = YES; //透明动画
CABasicAnimation *opacityAnim = [CABasicAnimation animationWithKeyPath:@"alpha"];
opacityAnim.fromValue = [NSNumber numberWithFloat:1.0];
opacityAnim.toValue = [NSNumber numberWithFloat:0.1];
opacityAnim.removedOnCompletion = YES;

4. UIViewAnimationWithBlocks

+ (void)transitionWithView:(UIView *)view duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options animations:(void (^ __nullable)(void))animations completion:(void (^ __nullable)(BOOL finished))completion
+ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^ __nullable)(BOOL finished))completion

// UIViewAnimationOptions

UIViewAnimationOptionLayoutSubviews //提交动画的时候布局子控件,表示子控件将和父控件一同动画。

UIViewAnimationOptionAllowUserInteraction //动画时允许用户交流,比如触摸

UIViewAnimationOptionBeginFromCurrentState //从当前状态开始动画

UIViewAnimationOptionRepeat //动画无限重复

UIViewAnimationOptionAutoreverse //执行动画回路,前提是设置动画无限重复

UIViewAnimationOptionOverrideInheritedDuration //忽略外层动画嵌套的执行时间

UIViewAnimationOptionOverrideInheritedCurve //忽略外层动画嵌套的时间变化曲线

UIViewAnimationOptionAllowAnimatedContent //通过改变属性和重绘实现动画效果,如果key没有提交动画将使用快照

UIViewAnimationOptionShowHideTransitionViews //用显隐的方式替代添加移除图层的动画效果

UIViewAnimationOptionOverrideInheritedOptions //忽略嵌套继承的选项

//时间函数曲线相关

UIViewAnimationOptionCurveEaseInOut //时间曲线函数,由慢到快

UIViewAnimationOptionCurveEaseIn //时间曲线函数,由慢到特别快

UIViewAnimationOptionCurveEaseOut //时间曲线函数,由快到慢

UIViewAnimationOptionCurveLinear //时间曲线函数,匀速

//转场动画相关的

UIViewAnimationOptionTransitionNone //无转场动画

UIViewAnimationOptionTransitionFlipFromLeft //转场从左翻转

UIViewAnimationOptionTransitionFlipFromRight //转场从右翻转

UIViewAnimationOptionTransitionCurlUp //上卷转场

UIViewAnimationOptionTransitionCurlDown //下卷转场

UIViewAnimationOptionTransitionCrossDissolve //转场交叉消失

UIViewAnimationOptionTransitionFlipFromTop //转场从上翻转

UIViewAnimationOptionTransitionFlipFromBottom //转场从下翻转

测试demo:https://github.com/lvdachao/animation

ios animation 动画效果实现的更多相关文章

  1. iOS各种动画效果

    ios各种动画效果 最普通动画: //开始动画 [UIView beginAnimations:nil context:nil];  //设定动画持续时间 [UIView setAnimationDu ...

  2. Android中xml设置Animation动画效果详解

    在 Android 中, Animation 动画效果的实现可以通过两种方式进行实现,一种是 tweened animation 渐变动画,另一种是 frame by frame animation ...

  3. android中设置Animation 动画效果

    在 Android 中, Animation 动画效果的实现可以通过两种方式进行实现,一种是 tweened animation 渐变动画,另一种是 frame by frame animation ...

  4. 模仿百度首页“元宵节汤圆”动图,并实现360°不停旋转(CSS3的animation动画效果)

    模仿百度首页“元宵节汤圆”动图,并实现360°不停旋转(CSS3的animation动画效果) 效果图: 切图地址: https://ss1.bdstatic.com/5eN1bjq8AAUYm2zg ...

  5. Swift 实现iOS Animation动画教程

    这是一篇翻译文章.原文出处:http://www.raywenderlich.com/95910/uiview-animation-swift-tutorial 动画( animation)是iOS用 ...

  6. iOS的动画效果类型及实现方法

    实现iOS漂亮的动画效果主要有两种方法, 一种是UIView层面的, 一种是使用CATransition进行更低层次的控制, 第一种是UIView,UIView方式可能在低层也是使用CATransit ...

  7. android Animation 动画效果介绍

    Android的animation由四种类型组成 XML中 alpha 渐变透明度动画效果 scale 渐变尺寸伸缩动画效果 translate 画面转换位置移动动画效果 rotate 画面转移旋转动 ...

  8. iOS开动画效果之──实现 pushViewController 默认动画效果

    在开发中,视图切换会常常遇到,有时我们不是基于导航控制器的切换,但实际开发中,有时需要做成push效果,下面将如何实现push和pop 默认动画效果代码实例: 一.push默认动画效果 CATrans ...

  9. Android Animation动画效果简介

    AlphaAnimation 淡入淡出动画  <alpha>A fade-in or fade-out animation. Represents an AlphaAnimation. a ...

随机推荐

  1. spring源码浅析——IOC

    =========================================== 原文链接: spring源码浅析--IOC   转载请注明出处! ======================= ...

  2. Canada Cup 2016 C. Hidden Word

    C. Hidden Word time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...

  3. http-server 命令行

    安装 (全局安装加 -g) : npm install http-server (npm install --global http-server) 在站点目录下开启命令行输入 http server ...

  4. C#中static void Main(string[] args) 参数详解

    学习C#编程最常见的示例程序是在控制台应用程序中输出Hello World! using System; namespace DemoMainArgs { class Program { static ...

  5. 1935: [Shoi2007]Tree 园丁的烦恼

    1935: [Shoi2007]Tree 园丁的烦恼 Time Limit: 15 Sec  Memory Limit: 357 MBSubmit: 648  Solved: 273[Submit][ ...

  6. 字符编码的种类:ASCII、GB2312、GBK、GB18030、Unicode、UTF-8、UTF-16、Base64

    ASCII码ASCII:https://zh.wikipedia.org/wiki/ASCIIASCII(American Standard Code for Information Intercha ...

  7. ubuntu 虚拟机vm virtualbox 不能打开 win7

    ubuntu某方面总有些不便,下载个虚拟机装个win7 但是第二次打开的时候就出现了安装是的场景: 原因很简单: 是因为安装了之后没有把win7的镜像文件移除,每次打开时会检测cd/dvd文件/(is ...

  8. DapperPoco -- 基于Dapper的、轻量级的、高性能的、简单的、灵活的ORM框架

    为什么要重复造轮子 因为现有的轮子都在某些方面不太令我满意,下面我来一一点评一下,欢迎拍砖. Entity Framework 我喜欢傻瓜化使用方式的框架,同时又不失灵活性. EF虽然使用起来足够简单 ...

  9. JavaScript 再认识(一):Function调用模式对this的影响

    近来,学习了一下<JavaScript精粹>,读到了函数这章,理清了JavaScript中this在不同调用模式下的指向. 1.Function调用模式:Function是JavaScri ...

  10. ICC_lab总结——ICC_lab1:数据设置和基本流程

    ICC_lab总结 最近在学习后端的流程,做lab是最好不过了.但是有时候做过了lab,过了一段时间之后就会忘记,因此需要自己总结一下,加强印象. ICC_lab1:数据设置和基本流程 数据设置: 一 ...