CAMediaTiming 小记

beginTime 动画开始时的延迟,比如延迟0.5秒执行,默认0,也就是马上开始

duration 动画持续时间,默认0

speed 动画速度,默认1,如果duration = 10,speed = 2, 那实际上动画5秒钟就执行完了。 设置为0会暂停动画,大于1会快进,0~1会减慢动画,小于0会倒退

timeOffset 动画快进到某一时间,不受speed影响,t = (tp – begin) * speed + offset

repeatCount 重复次数

repeatDuration 重复时间,和repeatCount不能同时设置

autoreverses 是否自动往复,默认no

fillMode 设置开始和结束时的填充,默认为removed,`backwards’, `forwards’, `both’ and `removed’,可以解决关键帧动画结束后跳帧的问题

CAMediaTimingFunction 简单的动画缓冲处理类,实际为三次贝塞尔曲线

public let kCAMediaTimingFunctionLinear: String 线性 (0.0,0.0)(0.0,0.0)(1.0,1.0)(1.0,1.0)

public let kCAMediaTimingFunctionEaseIn: String 淡入,先慢后快 (0.0,0.0)(0.42,0.0)(1.0,1.0)(1.0,1.0)

public let kCAMediaTimingFunctionEaseOut: String 淡出,先快后慢 (0.0,0.0)(0.0,0.0)(0.58,1.0)(1.0,1.0)

public let kCAMediaTimingFunctionEaseInEaseOut: String 淡入淡出,两头慢中间快 (0.0,0.0)(0.42,0.0)(0.58,1.0)(1.0,1.0)

public let kCAMediaTimingFunctionDefault: String 这个比较特殊 (0.0,0.0)(0.25,0.1)(0.25,1.0)(1.0,1.0)

public init(controlPoints c1x: Float, _ c1y: Float, _ c2x: Float, _ c2y: Float) 自定义缓冲曲线的方法
c1x = controlPoint1.x
c1y = controlPoint1.y
c2x = controlPoint2.x
c2y = controlPoint2.y

自定义缓冲函数实现
http://www.robertpenner.com/easing

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注