Instance Method

convertTime(_:to:)

Converts the time interval from the receiver’s time space to the specified layer’s time space

Declaration

func convertTime(_ t: CFTimeInterval, to l: CALayer?) -> CFTimeInterval

Parameters

t

A point specifying a location in the coordinate system of l.

l

The layer into whose time space t is to be converted. The receiver and l and must share a common parent layer.

Return Value

The time interval converted to the time space of layer.

Discussion

Listing 1 shows the creation of two layers, layer and offsetSlowMoLayer. offsetSlowMoLayer has an offset time of 1 second and its speed is set to 0.5. The last line converts and prints a time interval of 0.5 seconds converted from the time space of layer to the time space of offsetSlowMoLayer.

Listing 1

Converting between layer time spaces

let layer = CALayer()
let offsetSlowMoLayer = CALayer()
     
offsetSlowMoLayer.timeOffset = CFTimeInterval(1)
offsetSlowMoLayer.speed = 0.5
     
print(layer.convertTime(CFTimeInterval(0.5), to: offsetSlowMoLayer)) // prints 1.25

See Also

Mapping Between Coordinate and Time Spaces

func convert(CGPoint, from: CALayer?) -> CGPoint

Converts the point from the specified layer’s coordinate system to the receiver’s coordinate system.

func convert(CGPoint, to: CALayer?) -> CGPoint

Converts the point from the receiver’s coordinate system to the specified layer’s coordinate system.

func convert(CGRect, from: CALayer?) -> CGRect

Converts the rectangle from the specified layer’s coordinate system to the receiver’s coordinate system.

func convert(CGRect, to: CALayer?) -> CGRect

Converts the rectangle from the receiver’s coordinate system to the specified layer’s coordinate system.

func convertTime(CFTimeInterval, from: CALayer?) -> CFTimeInterval

Converts the time interval from the specified layer’s time space to the receiver’s time space.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software