SLCoreAnimation Class Reference

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

Overview

SLCoreAnimation support is experimental and should generally be used for simple, performance-critical animations. In a lot of scenarios it might deviate from what you are seeing in After Effects. SLCoreAnimations are less susceptible to stalls on the main thread and are therefore more suitable for situations when the CPU load is high.

Other Methods

  buildDelegate

A delegate to control how and if animations are added to specific AE layers.

@property (nonatomic, weak) id<SLCoreAnimationBuildDelegate> _Nullable buildDelegate

Declared In

SLCoreAnimation.h

+ animationFromBundle:error:

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

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

Parameters

fileName

.sqa file name of the animation to build

error

Optional pointer to an NSError

Return Value

SLCoreAnimation or nil on error

Declared In

SLCoreAnimation.h

+ animationFromBundle:

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

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

Parameters

fileName

.sqa file name of the animation to build

Return Value

SLCoreAnimation or nil on error.

Declared In

SLCoreAnimation.h

+ animationFromPath:error:

Convenience method to initialize a SLCoreAnimation with an animation file from the passed-in path.

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

Parameters

path

Path to an .sqa file

error

Optional pointer to an NSError

Return Value

SLCoreAnimation or nil on error

Declared In

SLCoreAnimation.h

Other Methods

– time

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

- (NSTimeInterval)time

Declared In

SLAnimation.h

– 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

– rate

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

- (CGFloat)rate

Declared In

SLAnimation.h

– setRate:

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

- (void)setRate:(CGFloat)rate

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

– progress

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

- (CGFloat)progress

Declared In

SLAnimation.h

– setProgress:

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

- (void)setProgress:(CGFloat)progress

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

– 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