One Logo Pool Ball
RealityFoundation · IOS API REFERENCE

AnimationView

struct · iOS 15.0+ · SDK 27.1

struct AnimationView

An animation that represents a variation of another animation. This structure creates a variation of an existing animation by overriding its configuration. The term _view_ in the name signifies that the variation represents a new visual perspective of the existing animation. ### Create a clip of an animation By supplying a new beginning time (``AnimationView/trimStart``) and ending time (``AnimationView/trimEnd``), the following code creates a shorter clip of an existing animation. With ``AnimationView/trimStart`` set to `1.0` and ``AnimationView/trimEnd`` at `2.0`, the clip spans a one-second duration. ```swift // Create or access an existing animation. let anim1 = FromToByAnimation<Float>(name: "Anim1", from: 100.0, to: 200.0, duration: 10.0) // Use a view to create a clip of the original animation. let view = AnimationView(source: anim1, name: "clip", bindTarget: nil, blendLayer: 0, repeatMode: .autoReverse, fillMode: [], trimStart: 1.0, trimEnd: 2.0, trimDuration: nil, offset: 0, delay: 0, speed: 1.0) // Create an animation resource from the clip. clipResource = try? AnimationResource.generate(with: view) // Play the clip. myModelEntity.playAnimation(clipResource) ``` ### Define a view in relation to the animation source The source animation's timing properties define a _timeline_ on which the ``AnimationView/trimDuration``, ``AnimationView/delay``, and ``AnimationView/speed`` properties operate to derive the view. The ``AnimationView/trimDuration`` property specifies which animation data the view displays. If ``AnimationView/trimDuration`` exceeds the length of the source animation’s timeline, the animation plays according to the characteristics of ``AnimationView/repeatMode``. The ``AnimationView/delay`` property defines a waiting period before the animation begins, and the ``AnimationView/speed`` determines how fast the view plays in relation to the original pace.

Members (26)

get · iOS 15.0+

bindTarget

TypeScript
get bindTarget(): BindTarget
Swift declaration
var bindTarget: BindTarget { get set }

A textual name that identifies the animated property. The property name is a key path. For more information on key paths, see <doc://com.apple.documentation/documentation/swift/swift_standard_library/key-path_expressions>.

set · iOS 15.0+

bindTarget

TypeScript
set bindTarget(value: BindTarget)
Swift declaration
var bindTarget: BindTarget { get set }

A textual name that identifies the animated property. The property name is a key path. For more information on key paths, see <doc://com.apple.documentation/documentation/swift/swift_standard_library/key-path_expressions>.

get · iOS 15.0+

blendLayer

TypeScript
get blendLayer(): number
Swift declaration
var blendLayer: Int32 { get set }

The order in which the framework composites the animation. The framework applies multiple animations on the same target in ascending order of this property’s value. Animations in a lower layer run before animations in a higher layer. Animations that share the same value apply in the order that they execute.

set · iOS 15.0+

blendLayer

TypeScript
set blendLayer(value: number)
Swift declaration
var blendLayer: Int32 { get set }

The order in which the framework composites the animation. The framework applies multiple animations on the same target in ascending order of this property’s value. Animations in a lower layer run before animations in a higher layer. Animations that share the same value apply in the order that they execute.

get · iOS 15.0+

repeatMode

TypeScript
get repeatMode(): AnimationRepeatMode
Swift declaration
var repeatMode: AnimationRepeatMode { get set }

An option that determines how the animation repeats. If you call ``AnimationView/trimmed(start:end:duration:)`` with a `start` or `end` that lies outside of the timeline defined by ``AnimationView/duration``, the animation fills the additional playback by applying this property.

set · iOS 15.0+

repeatMode

TypeScript
set repeatMode(value: AnimationRepeatMode)
Swift declaration
var repeatMode: AnimationRepeatMode { get set }

An option that determines how the animation repeats. If you call ``AnimationView/trimmed(start:end:duration:)`` with a `start` or `end` that lies outside of the timeline defined by ``AnimationView/duration``, the animation fills the additional playback by applying this property.

get · iOS 15.0+

trimDuration

TypeScript
get trimDuration(): (number) | null
Swift declaration
var trimDuration: TimeInterval? { get set }

An optional duration that overrides the calculated duration. The framework calculates ``AnimationView/duration``, but you can set this property to override it. This property is `nil` by default, which indicates that the animation stops after one play that spans ``AnimationView/duration``. If you set a non-zero value for this property and both ``AnimationView/trimStart`` and ``AnimationView/trimEnd`` are `nil`, the animation observes this property as an edited duration. When you set ``AnimationView/repeatMode`` to make the animation repeat: - If this property is `nil`, the animation repeats forever. - If set to a value greater than ``AnimationView/duration``, the animation repeats for the specified duration.

set · iOS 15.0+

trimDuration

TypeScript
set trimDuration(value: (number) | null)
Swift declaration
var trimDuration: TimeInterval? { get set }

An optional duration that overrides the calculated duration. The framework calculates ``AnimationView/duration``, but you can set this property to override it. This property is `nil` by default, which indicates that the animation stops after one play that spans ``AnimationView/duration``. If you set a non-zero value for this property and both ``AnimationView/trimStart`` and ``AnimationView/trimEnd`` are `nil`, the animation observes this property as an edited duration. When you set ``AnimationView/repeatMode`` to make the animation repeat: - If this property is `nil`, the animation repeats forever. - If set to a value greater than ``AnimationView/duration``, the animation repeats for the specified duration.

get · iOS 15.0+

name

TypeScript
get name(): string
Swift declaration
var name: String { get set }

A textual name for the animation.

set · iOS 15.0+

name

TypeScript
set name(value: string)
Swift declaration
var name: String { get set }

A textual name for the animation.

get · iOS 15.0+

delay

TypeScript
get delay(): number
Swift declaration
var delay: TimeInterval { get set }

An amount of time that lapses before the animation plays. The default value is `0`, which indicates that the animation plays with no delay. If you set a value for this property, the animation plays from its start time after the specified delay lapses. During the delayed time, the animation doesn't update. However, to fill the delayed time with some portion of animation, set a negative ``AnimationView/trimStart`` instead and choose a ``AnimationView/fillMode`` that displays the desired portion of animation.

set · iOS 15.0+

delay

TypeScript
set delay(value: number)
Swift declaration
var delay: TimeInterval { get set }

An amount of time that lapses before the animation plays. The default value is `0`, which indicates that the animation plays with no delay. If you set a value for this property, the animation plays from its start time after the specified delay lapses. During the delayed time, the animation doesn't update. However, to fill the delayed time with some portion of animation, set a negative ``AnimationView/trimStart`` instead and choose a ``AnimationView/fillMode`` that displays the desired portion of animation.

get · iOS 15.0+

speed

TypeScript
get speed(): number
Swift declaration
var speed: Float { get set }

A factor that increases or decreases the animation’s rate of playback. The default value is `1.0`, which doesn’t alter the animation’s duration. A value of `2.0` indicates that the duration is half the underlying setting. A value of `0.5` indicates that the duration is twice the underlying setting. Negative values play the animation in reverse. This property doesn’t affect the animation’s ``AnimationView/delay``.

set · iOS 15.0+

speed

TypeScript
set speed(value: number)
Swift declaration
var speed: Float { get set }

A factor that increases or decreases the animation’s rate of playback. The default value is `1.0`, which doesn’t alter the animation’s duration. A value of `2.0` indicates that the duration is half the underlying setting. A value of `0.5` indicates that the duration is twice the underlying setting. Negative values play the animation in reverse. This property doesn’t affect the animation’s ``AnimationView/delay``.

get · iOS 15.0+

offset

TypeScript
get offset(): number
Swift declaration
var offset: TimeInterval { get set }

The time, in seconds, at which the animation begins within the duration. The default value is `0`, which indicates that the animation plays with no offset. Setting a value for this property moves the animation data along the timeline and doesn't change timing. If you set a ``SampledAnimation/fillMode`` other than ``AnimationFillMode/none``, the animation fills the vacant area created by the offset according to the characteristics of the specified fill mode.

set · iOS 15.0+

offset

TypeScript
set offset(value: number)
Swift declaration
var offset: TimeInterval { get set }

The time, in seconds, at which the animation begins within the duration. The default value is `0`, which indicates that the animation plays with no offset. Setting a value for this property moves the animation data along the timeline and doesn't change timing. If you set a ``SampledAnimation/fillMode`` other than ``AnimationFillMode/none``, the animation fills the vacant area created by the offset according to the characteristics of the specified fill mode.

init · iOS 15.0+

init

TypeScript
static init(source: SDKHandle, name?: string, bindTarget?: (BindTarget) | null, blendLayer?: number, repeatMode?: AnimationRepeatMode, fillMode?: AnimationFillMode, trimStart?: (number) | null, trimEnd?: (number) | null, trimDuration?: (number) | null, offset?: number, delay?: number, speed?: number): AnimationView
Swift declaration
init(source: any AnimationDefinition, name: String = "", bindTarget: BindTarget? = nil, blendLayer: Int32 = 0, repeatMode: AnimationRepeatMode = .none, fillMode: AnimationFillMode = [], trimStart: TimeInterval? = nil, trimEnd: TimeInterval? = nil, trimDuration: TimeInterval? = nil, offset: TimeInterval = 0, delay: TimeInterval = 0, speed: Float = 1.0)

Creates a variation of the given animation by overriding its properties. - Parameters: - source: The original animation that this structure modifies. - name: A textual name for the animation. - bindTarget: A textual name that identifies the animated property. - blendLayer: The order in which the framework visually composites the animation among other running animations. - repeatMode: An option that determines how the animation repeats outside the length of the view. - fillMode: The behavior when the animated property reaches its end value. - trimStart: The optional time, in seconds, at which the source animation plays. - trimEnd: The optional time, in seconds, at which the source animation stops. - trimDuration: An optional duration that overrides the calculated duration. - offset: The time, in seconds, at which the animation begins within the duration. - delay: An amount of time that lapses before the animation plays. - speed: A factor that increases or decreases the animation’s playback rate.

get · iOS 15.0+

source

TypeScript
get source(): (SDKHandle) | null
Swift declaration
var source: (any AnimationDefinition)? { get set }

The original animation that this structure modifies.

set · iOS 15.0+

source

TypeScript
set source(value: (SDKHandle) | null)
Swift declaration
var source: (any AnimationDefinition)? { get set }

The original animation that this structure modifies.

get · iOS 15.0+

trimEnd

TypeScript
get trimEnd(): (number) | null
Swift declaration
var trimEnd: TimeInterval? { get set }

The time, in seconds, at which the source animation stops. This property is `nil` by default, which plays the animation until `time` = ``AnimationView/duration``. If you set a value, the animation edits the duration according to the specified ending time.

set · iOS 15.0+

trimEnd

TypeScript
set trimEnd(value: (number) | null)
Swift declaration
var trimEnd: TimeInterval? { get set }

The time, in seconds, at which the source animation stops. This property is `nil` by default, which plays the animation until `time` = ``AnimationView/duration``. If you set a value, the animation edits the duration according to the specified ending time.

get · iOS 15.0+

duration

TypeScript
get duration(): number
Swift declaration
var duration: TimeInterval { get }

The total playback time of the animation. The framework sets a value for this property depending on the underlying animation data and the specified ``AnimationView/speed``. You can override the default duration by defining ``AnimationView/trimStart``, ``AnimationView/trimEnd``, or ``AnimationView/trimDuration``.

get · iOS 15.0+

fillMode

TypeScript
get fillMode(): AnimationFillMode
Swift declaration
var fillMode: AnimationFillMode { get set }

An option that determines which data displays outside of the normal duration. This property determines what to display when the framework samples the animation outside of the range defined by its underlying duration. The animation applies this property when: - Playback progresses toward, but hasn't yet reached, a nonzero ``AnimationView/offset``. - A range determined by ``AnimationView/trimStart``, ``AnimationView/trimEnd``, or ``AnimationView/trimDuration`` exceeds the animation's underlying duration.

set · iOS 15.0+

fillMode

TypeScript
set fillMode(value: AnimationFillMode)
Swift declaration
var fillMode: AnimationFillMode { get set }

An option that determines which data displays outside of the normal duration. This property determines what to display when the framework samples the animation outside of the range defined by its underlying duration. The animation applies this property when: - Playback progresses toward, but hasn't yet reached, a nonzero ``AnimationView/offset``. - A range determined by ``AnimationView/trimStart``, ``AnimationView/trimEnd``, or ``AnimationView/trimDuration`` exceeds the animation's underlying duration.

get · iOS 15.0+

trimStart

TypeScript
get trimStart(): (number) | null
Swift declaration
var trimStart: TimeInterval? { get set }

The time, in seconds, at which the source animation plays. This property is `nil` by default, which plays the animation with `time` = `0`. If you set a value, the animation edits the duration according to the specified beginning time. If you set a negative value for this property, the duration increases and the additional animation data fills in based on the ``AnimationView/fillMode`` you choose.

set · iOS 15.0+

trimStart

TypeScript
set trimStart(value: (number) | null)
Swift declaration
var trimStart: TimeInterval? { get set }

The time, in seconds, at which the source animation plays. This property is `nil` by default, which plays the animation with `time` = `0`. If you set a value, the animation edits the duration according to the specified beginning time. If you set a negative value for this property, the duration increases and the additional animation data fills in based on the ``AnimationView/fillMode`` you choose.

Skipped declarations

No declarations were skipped in this snapshot.

All RealityFoundation types →