RBBAnimation

RBBAnimation is a subclass of CAKeyframeAnimation that allows you to declare your animations using blocks instead of writing out all the individual key-frames.

This gives you greater flexibility when specifying your animations while keeping your code concise.

It comes out of the box with a replacement for CASpringAnimationsupport for custom easing functions such as bouncing as well as hooks to allow your writing your own animations fully from scratch.

RBBAnimation继承自CAKeyframeAnimation,允许你在block中设置你所需要的动画属性,而不是在外面单独的写键值对。当你既想着要实现动画效果,又想保持你的代码看起来清爽,毫无疑问RBBAnimation是你不二的选择。

Installation(安装)

To install RBBAnimation, I recommend the excellent CocoaPods. Simply add this to your Podfile

pod 'RBBAnimation', '0.3.0'

and you are ready to go!

If you'd like to run the bundled test app, make sure to install its dependencies by running

pod install

after cloning the repo.

我建议你使用CocoaPods安装吧。

RBBCustomAnimation(自定义动画)

Use RBBCustomAnimation to create arbitrary animations by passing in an RBBAnimationBlock:

使用RBBCustomAnimation来创建直观的自定义动画,在RBBAnimationBlock中设置即可。

RBBCustomAnimation *rainbow = [RBBCustomAnimation animationWithKeyPath:@"backgroundColor"];

rainbow.animationBlock = ^(CGFloat elapsed, CGFloat duration) {
UIColor *color = [UIColor colorWithHue:elapsed / duration
saturation:1
brightness:1
alpha:1]; return (id)color.CGColor;
};

The arguments of the block are the current position of the animation as well as its total duration.

Most of the time, you will probably want to use the higher-level RBBTweenAnimation.

block中的参数就是你要设置动画的参数,以及需要你配置一个动画持续的时间。

大部分时间,你需要使用更高级别上的RBBTweenAnimation。

RBBSpringAnimation(精灵动画)

RBBSpringAnimation is a handy replacement for the private CASpringAnimation. Specify your spring's mass, damping, stiffness as well as its initial velocity and watch it go:

RBBSpringAnimation是用来替换这个私有方法CASpringAnimation。指定你精灵对象的质量,阻尼,生硬程度以及他的速率,参考如下:

RBBSpringAnimation *spring = [RBBSpringAnimation animationWithKeyPath:@"position.y"];

spring.fromValue = @(-100.0f);
spring.toValue = @(100.0f);
spring.velocity = 0;
spring.mass = 1;
spring.damping = 10;
spring.stiffness = 100; spring.additive = YES;
spring.duration = [spring durationForEpsilon:0.01];

RBBTweenAnimation(两点之间的动画)

RBBTweenAnimation allows you to animate from one value to another, similar to CABasicAnimation but with a greater flexibility in how the values should be interpolated.

It supports the same cubic Bezier interpolation that you get from CAMediaTimingFunction using the RBBCubicBezier helper function:

RBBTweenAnimation允许你从一个值动态变化到另外一个值,就像CABasicAnimation一样,但是呢,对于如何设置参数更加便利。

它同样支持你篡改立方体贝塞尔曲线,你可以从CAMediaTimingFunction中使用RBBCubicBezier来获取一些帮助信息:

RBBTweenAnimation *easeInOutBack = [RBBTweenAnimation animationWithKeyPath:@"position.y"];

easeInOutBack.fromValue = @(-100.0f);
easeInOutBack.toValue = @(100.0f);
easeInOutBack.easing = RBBCubicBezier(0.68, -0.55, 0.265, 1.55); easeInOutBack.additive = YES;
easeInOutBack.duration = 0.6;

However, RBBTweenAnimation also supports more complex easing functions such as RBBEasingFunctionEaseOutBounce:

当然,RBBTweenAnimation支持更复杂的easing方法,例如RBBEasingFunctionEaseOutBounce:

RBBTweenAnimation *bounce = [RBBTweenAnimation animationWithKeyPath:@"position.y"];
bounce.fromValue = @(-100);
bounce.toValue = @(100);
bounce.easing = RBBEasingFunctionEaseOutBounce; bounce.additive = YES;
bounce.duration = 0.8;

You can also specify your own easing functions, from scratch:

你也可以使用你自己定制的easiing函数:

RBBTweenAnimation *sinus = [RBBTweenAnimation animationWithKeyPath:@"position.y"];
sinus.fromValue = @(0);
sinus.toValue = @(100); sinus.easing = ^CGFloat (CGFloat fraction) {
return sin((fraction) * 2 * M_PI);
}; sinus.additive = YES;
sinus.duration = 2;

[翻译] RBBAnimation,让你使用关键帧动画更便利的更多相关文章

  1. 《Programming WPF》翻译 第8章 4.关键帧动画

    原文:<Programming WPF>翻译 第8章 4.关键帧动画 到目前为止,我们只看到简单的点到点的动画.我们使用了To和From属性或者By属性来设计动画--相对于当前的属性值.这 ...

  2. Windows Store App 关键帧动画

    关键帧动画和插值动画类似,同样可以根据目标属性值的变化产生相应的动画效果,不同的是,插值动画是在两个属性值之间进行渐变,而关键帧动画打破了仅通过两个属性值控制动画的局限性,它可以在任意多个属性值之间进 ...

  3. IOS开发-属性动画和关键帧动画的使用

    CAMediaTiming是一个协议(protocol),CAAnimation是所有动画类的父类,但是它不能直接使用,应该使用它的子类. 继承关系: CoreAnmiation 核心动画 简写CA ...

  4. Silverlight动画的基本知识、关键帧动画

    基础知识 (一)动画:是快速播放一系列图像(其中每个图像与下一个图像略微不同)给人造成的一种幻觉 (二)动画类型:两类    (1)From/To/By动画:在起始值和结束值之间进行动画处理.     ...

  5. Windows Phone开发(41):漫谈关键帧动画之下篇

    原文:Windows Phone开发(41):漫谈关键帧动画之下篇 也许大家已经发现,其实不管什么类型的动画,使用方法基本是一样的,不知道大家总结出规律了没有?当你找到规律之后,你会发现真的可以举一反 ...

  6. Windows Phone开发(39):漫谈关键帧动画上篇

    原文:Windows Phone开发(39):漫谈关键帧动画上篇 尽管前面介绍的几种动画会让觉得很好玩了,但是,不知道你是否发现,在前面说到的一系列XXXAnimation中,都有一个共同点,那就是仅 ...

  7. Core Animation中的关键帧动画

    键帧动画就是在动画控制过程中开发者指定主要的动画状态,至于各个状态间动画如何进行则由系统自动运算补充(每两个关键帧之间系统形成的动画称为“补间动画”),这种动画的好处就是开发者不用逐个控制每个动画帧, ...

  8. ios基础动画、关键帧动画、动画组、转场动画等

    概览 在iOS中随处都可以看到绚丽的动画效果,实现这些动画的过程并不复杂,今天将带大家一窥iOS动画全貌.在这里你可以看到iOS中如何使用图层精简非交互式绘图,如何通过核心动画创建基础动画.关键帧动画 ...

  9. WPF中的动画——(五)关键帧动画

    与 From/To/By 动画类似,关键帧动画以也可以以动画形式显示目标属性值. 和From/To/By 动画不同的是, From/To/By 动画只能控制在两个状态之间变化,而关键帧动画则可以在多个 ...

随机推荐

  1. 开源框架:SDWebImage

    http://blog.csdn.net/uxyheaven/article/details/7909373 SDWebImage是我搞iOS以来少数佩服的框架,膜拜一下作者.真的写的非常棒! 这套开 ...

  2. [转载]Visual Studio 各版本下载

    文件名称 文件大小 百度网盘下载 微软官方下载 Visual Studio 2015 Enterprise - 企业版 - 简体中文 3.89GB http://pan.baidu.com/s/1bn ...

  3. Zookeeper学习笔记-概念介绍

    目录 概念 背景介绍 zookeeper一致性 使用建议 概念 ZooKeeper是一个开源的分布式协调服务,它为分布式应用提供了高效且可靠的分布式协调服务,提供的功能包括:配置维护.域名服务.分布式 ...

  4. USACO 6.2 Packing Rectangles

    Packing RectanglesIOI 95 The six basic layouts of four rectangles Four rectangles are given. Find th ...

  5. LoadRunner中的随机数

    LoadRunner中的随机数 Action() { int i; ]; srand(time(NULL)); i=rand()%; lr_save_datetime("%m%d%H%M%S ...

  6. Centos 7.2 安装 Python 3.5(适用于Python 3所有版本安装)

    提示:我们必须不能破坏系统的环境.因为几个关键的应用程序依赖于Python 2.7.5(centos 7默认版本).如果替换了系统的Python环境就会发生很多难以预见的错误,甚至要重装系统. 安装前 ...

  7. python opencv入门-形态学转换

    目标: 学习不同的形态操作 例如 腐蚀.膨胀.开运算.闭运算 等. 我们要学习的函数有 cv2.erode(),cv2.dilate(),cv2.morphologyEx() 等. 原理 :一般对二值 ...

  8. CentOS查看内核版本、系统版本、系统位数

    http://blog.51cto.com/ultrasql/1640435

  9. android 后台 activity 被系统回收 保存状态

    韩梦飞沙  韩亚飞  313134555@qq.com  yue31313  han_meng_fei_sha 活动被系统回收, 要保存状态 ,用到 活动的 在保存实例时候 的 这个方法. 当系统异常 ...

  10. hdu 4548 初始化+二分 *

    题意:小明对数的研究比较热爱,一谈到数,脑子里就涌现出好多数的问题,今天,小明想考考你对素数的认识.问题是这样的:一个十进制数,如果是素数,而且它的各位数字和也是素数,则称之为“美素数”,如29,本身 ...