SLSquallAnimation Class Reference

Inherits from SLAnimation : CALayer
Declared in SLSquallAnimation.h
SLSquallAnimation.mm

Overview

SLSquallAnimation is backed by a CADisplayLink and updates the animation whenever the display refreshes.

This type of animation will be the most faithful to what you are seeing in After Effects.

All of the updates occur on the main thread. SLSquallAnimations are therefore more susceptible to stalls from heavy CPU load than SLCoreAnimation.

SLSquallAnimation* animation = [SLSquallAnimation animationFromBundle:@"myAnimation.sqa"];
[animation play];
[self.layer addSublayer:animation];
SWIFT
let animation = SLCoreAnimation(fromBundle: "myAnimation.sqa")
animation.play()
self.view.layer.addSublayer(animation!);

@performance Do not use in highly constrained performance situations.

Other Methods

+ animationFromBundle:error:

Convenience method to initialize a SLSquallAnimation with a .sqa file contained in your main app bundle.

+ (SLSquallAnimation *_Nonnull)animationFromBundle:(NSString *_Nonnull)fileName error:(NSError *_Nullable *_Nullable)error

Parameters

fileName

.sqa file name of the animation to build

error

Optional pointer to a NSError

Return Value

SLSquallAnimation or nil on error

Declared In

SLSquallAnimation.h

+ animationFromPath:error:

Convenience method to initialize a SLSquallAnimation with a .sqa file at the passed-in path.

+ (SLSquallAnimation *_Nonnull)animationFromPath:(NSString *_Nonnull)path error:(NSError *_Nullable *_Nullable)error

Parameters

path

Path to the .sqa file

error

Optional pointer to a NSError

Return Value

SLSquallAnimation or nil on error

Declared In

SLSquallAnimation.h

+ animationFromBundle:

Convenience method to initialize an SLSquallAnimation with an animation file contained in your main app bundle.

+ (SLSquallAnimation *_Nullable)animationFromBundle:(NSString *_Nonnull)fileName

Parameters

fileName

.sqa file name of the animation to build

Return Value

SLSquallAnimation or nil on error

Declared In

SLSquallAnimation.h

– parentLayerWithName:toLayer:error:

This method allows you to have an existing layer in your app inherit the 2D (!) transform transformations (position, scale, rotation, anchor point) from a layer in your AE animation. It works exactly like the parenting behavior in After Effects. Place your app layer wherever you need it, add it to the layer hierarchy and then call this method to tie it to a specific AE layer. The app layer will now behave as if glued to this AE layer.

- (void)parentLayerWithName:(NSString *_Nonnull)layerName toLayer:(CALayer *_Nonnull)layer error:(NSError *_Nullable *_Nullable)error

Parameters

layerName

AE layer name of the parent layer. Make sure it is unique.

layer

App layer to inherit the transformation of the AE layer. Must be part of the layer hierarchy.

error

Optional pointer to a NSError

Discussion

Warning: Do not modify the transform property on the app layer while the parent-child relationship.

Warning: Does not honor 3D transformations. is active.

Declared In

SLSquallAnimation.h

– removeParentFromLayer:

Call this method to dissolve a parent-child relationship.

- (void)removeParentFromLayer:(CALayer *_Nonnull)layer

Parameters

layer

The app layer that is tied to an AE layer.

Declared In

SLSquallAnimation.h

Other Methods

– setTime:

Time of the animation. Clamped to 0 and animation duration. (0 and 1 in evaluation mode).

- (void)setTime:(NSTimeInterval)time

Declared In

SLAnimation.h

– time

Time of the animation. Clamped to 0 and animation duration. (0 and 1 in evaluation mode).

- (NSTimeInterval)time

Declared In

SLAnimation.h

– setRate:

Determines the rate of playback of the animation. Default: 0.0

- (void)setRate:(CGFloat)rate

Declared In

SLAnimation.h

– setProgress:

Playback progression of the animation. Progress = time/animationDuration.

- (void)setProgress:(CGFloat)progress

Declared In

SLAnimation.h

– progress

Playback progression of the animation. Progress = time/animationDuration.

- (CGFloat)progress

Declared In

SLAnimation.h

– buildWithInformation:

Build an animation with an SLAnimationInformation object output by SLReader. It is usually easier to use one of the convencience methods to build an animation but this gives you the oportunity to tweak some settings before building the animation, e.g. adding an SLCoreAnimationBuildDelegate.

- (void)buildWithInformation:(SLAnimationInformation *)buildInformation

Parameters

buildInformation

information used to build the animation

Discussion

SLReader *reader = [[SLReader alloc] init];
NSError* error;
SLAnimationInformation *animationInformation = [reader parseFileFromBundle:@"myAnimation.sqa" error:&error];
if (!error) {
    SLSquallAnimation* animation = [[SLSquallAnimation alloc] init];
    [animation buildWithInformation:animationInformation];
    [self.layer addSublayer:animation];
    [animation play];
} else {
    NSLog(@"error %@", error);
}
SWIFT
let reader = SLReader()
var animationInformation : SLAnimationInformation?
do {
    animationInformation = try reader.parseFileFromBundle("myAnimation.sqa")
} catch {
    print("error \(error)")
}
if animationInformation != nil {
    let animation = SLSquallAnimation.init()
    animation.buildWithInformation(animationInfo)
    animation.play()
    self.layer.addSublayer(animation)
}

Declared In

SLAnimation.h

– play

Start playing the animation.

- (void)play

Declared In

SLAnimation.h

– pause

Pause the animation.

- (void)pause

Declared In

SLAnimation.h

– isPaused

Convenience method to test if the animation is currently paused. Equals rate == 0.0.

- (BOOL)isPaused

Return Value

BOOL

Declared In

SLAnimation.h