Extension
This extension adds a convenient variables to CAMediaTimingFunction.
public extension CAMediaTimingFunction
This extension defines conveniently accessible variables for standard media timing functions. It also defined a variable for accessing the reversed version of a timing function, as well as its control points.
A static definition of the linear timing function.
static let linear = CAMediaTimingFunction(name: CAMediaTimingFunctionName.linear)
A static definition of the easeIn timing function.
static let easeIn = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeIn)
A static definition of the easeOut timing function.
static let easeOut = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeOut)
A static definition of the easeInEaseOut timing function.
static let easeInEaseOut = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeInEaseOut)
Returns a new CAMediaTimingFunction
with reversed set of control points for the current timing function.
var reversed: CAMediaTimingFunction {
let (c1, c2) = controlPoints
let x1 = Float(1 - c2.x)
let y1 = Float(1 - c2.y)
let x2 = Float(1 - c1.x)
let y2 = Float(1 - c1.y)
return CAMediaTimingFunction(controlPoints: x1, y1, x2, y2)
}
Returns the control points for the current timing function.
var controlPoints: (CGPoint, CGPoint) {
var c1: [Float] = [0, 0]
var c2: [Float] = [0, 0]
getControlPoint(at: 1, values: &c1)
getControlPoint(at: 2, values: &c2)
let c1x = CGFloat(c1[0])
let c1y = CGFloat(c1[1])
let c2x = CGFloat(c2[0])
let c2y = CGFloat(c2[1])
return (CGPoint(x: c1x, y: c1y), CGPoint(x: c2x, y: c2y))
}
result(s) found for “”.