CAMediaTiming Protocol Reference

Adopted by
Framework
/System/Library/Frameworks/QuartzCore.framework
Availability
Available in iOS 2.0 and later.
Declared in
CAMediaTiming.h
Companion guides

Overview

The CAMediaTiming protocol models a hierarchical timing system, with each object describing the mapping of time values from the object's parent to local time.

Absolute time is defined as mach time converted to seconds. The CACurrentMediaTime function is provided as a convenience for getting the current absolute time.

The conversion from parent time to local time has two stages:

  1. Conversion to “active local time”. This includes the point at which the object appears in the parent object's timeline and how fast it plays relative to the parent.

  2. Conversion from “active local time” to “basic local time”. The timing model allows for objects to repeat their basic duration multiple times and, optionally, to play backwards before repeating.

Tasks

Animation Start Time

Repeating Animations

Duration and Speed

Playback Modes

Properties

autoreverses

Determines if the receiver plays in the reverse upon completion. (required)

@property BOOL autoreverses
Discussion

When YES, the receiver plays backwards after playing forwards. Defaults to NO.

Availability
  • Available in iOS 2.0 and later.
Declared In
CAMediaTiming.h

beginTime

Specifies the begin time of the receiver in relation to its parent object, if applicable. (required)

@property CFTimeInterval beginTime
Discussion

Defaults to 0.

Availability
  • Available in iOS 2.0 and later.
Declared In
CAMediaTiming.h

duration

Specifies the basic duration of the animation, in seconds. (required)

@property CFTimeInterval duration
Discussion

Defaults to 0.

Availability
  • Available in iOS 2.0 and later.
Related Sample Code
Declared In
CAMediaTiming.h

fillMode

Determines if the receiver’s presentation is frozen or removed once its active duration has completed. (required)

@property(copy) NSString *fillMode
Discussion

The possible values are described in “Fill Modes”. The default is kCAFillModeRemoved.

Availability
  • Available in iOS 2.0 and later.
Declared In
CAMediaTiming.h

repeatCount

Determines the number of times the animation will repeat. (required)

@property float repeatCount
Discussion

May be fractional. If the repeatCount is 0, it is ignored. Defaults to 0. If both repeatDuration and repeatCount are specified the behavior is undefined.

Setting this property to HUGE_VALF will cause the animation to repeat forever.

Availability
  • Available in iOS 2.0 and later.
Declared In
CAMediaTiming.h

repeatDuration

Determines how many seconds the animation will repeat for. (required)

@property CFTimeInterval repeatDuration
Discussion

Defaults to 0. If the repeatDuration is 0, it is ignored. If both repeatDuration and repeatCount are specified the behavior is undefined.

Availability
  • Available in iOS 2.0 and later.
Declared In
CAMediaTiming.h

speed

Specifies how time is mapped to receiver’s time space from the parent time space. (required)

@property float speed
Discussion

For example, if speed is 2.0 local time progresses twice as fast as parent time. Defaults to 1.0.

Availability
  • Available in iOS 2.0 and later.
Declared In
CAMediaTiming.h

timeOffset

Specifies an additional time offset in active local time. (required)

@property CFTimeInterval timeOffset
Discussion

Defaults to 0. .

Availability
  • Available in iOS 2.0 and later.
Declared In
CAMediaTiming.h

Constants

Fill Modes

These constants determine how the timed object behaves once its active duration has completed. They are used with the fillMode property.

NSString * const kCAFillModeRemoved;
NSString * const kCAFillModeForwards;
NSString * const kCAFillModeBackwards;
NSString * const kCAFillModeBoth;
NSString * const kCAFillModeFrozen;
Constants
kCAFillModeRemoved

The receiver is removed from the presentation when the animation is completed.

Available in iOS 2.0 and later.

Declared in CAMediaTiming.h.

kCAFillModeForwards

The receiver remains visible in its final state when the animation is completed.

Available in iOS 2.0 and later.

Declared in CAMediaTiming.h.

kCAFillModeBackwards

The receiver clamps values before zero to zero when the animation is completed.

Available in iOS 2.0 and later.

Declared in CAMediaTiming.h.

kCAFillModeBoth

The receiver clamps values at both ends of the object’s time space

Available in iOS 2.0 and later.

Declared in CAMediaTiming.h.

kCAFillModeFrozen

The mode was deprecated before OS X v10.5 shipped.

Available in iOS 2.0 and later.

Deprecated in iOS 4.0.

Declared in CAMediaTiming.h.

Declared In
CAMediaTiming.h