Merge pull request #394 from airbnb/btw/animatedcontrols

Added animated controls and switches
This commit is contained in:
Brandon Withrow 2017-08-28 14:42:40 -07:00 committed by GitHub
commit b0ddddac01
21 changed files with 1228 additions and 763 deletions

View File

@ -9,7 +9,7 @@ EXTERNAL SOURCES:
:path: "../" :path: "../"
SPEC CHECKSUMS: SPEC CHECKSUMS:
lottie-ios: 601c75ad9b5f27857f6221c5e7f4a12d23f5e779 lottie-ios: fdc7c231af7840661e673c31531ed4bae497d400
PODFILE CHECKSUM: fdbd59f361db8744871f0e9a0b3f94e0b7b8ca6b PODFILE CHECKSUM: fdbd59f361db8744871f0e9a0b3f94e0b7b8ca6b

View File

@ -26,7 +26,11 @@
"lottie-ios/Classes/PublicHeaders/LOTAnimationTransitionController.h", "lottie-ios/Classes/PublicHeaders/LOTAnimationTransitionController.h",
"lottie-ios/Classes/Private/LOTAnimationTransitionController.m", "lottie-ios/Classes/Private/LOTAnimationTransitionController.m",
"lottie-ios/Classes/PublicHeaders/LOTCacheProvider.h", "lottie-ios/Classes/PublicHeaders/LOTCacheProvider.h",
"lottie-ios/Classes/Private/LOTCacheProvider.m" "lottie-ios/Classes/Private/LOTCacheProvider.m",
"lottie-ios/Classes/PublicHeaders/LOTAnimatedSwitch.h",
"lottie-ios/Classes/Private/LOTAnimatedSwitch.m",
"lottie-ios/Classes/PublicHeaders/LOTAnimatedControl.h",
"lottie-ios/Classes/Private/LOTAnimatedControl.m"
], ],
"frameworks": [ "frameworks": [
"AppKit", "AppKit",

View File

@ -9,7 +9,7 @@ EXTERNAL SOURCES:
:path: "../" :path: "../"
SPEC CHECKSUMS: SPEC CHECKSUMS:
lottie-ios: 601c75ad9b5f27857f6221c5e7f4a12d23f5e779 lottie-ios: fdc7c231af7840661e673c31531ed4bae497d400
PODFILE CHECKSUM: fdbd59f361db8744871f0e9a0b3f94e0b7b8ca6b PODFILE CHECKSUM: fdbd59f361db8744871f0e9a0b3f94e0b7b8ca6b

File diff suppressed because it is too large Load Diff

View File

@ -2,6 +2,8 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#endif #endif
#import "LOTAnimatedControl.h"
#import "LOTAnimatedSwitch.h"
#import "LOTAnimationCache.h" #import "LOTAnimationCache.h"
#import "LOTAnimationTransitionController.h" #import "LOTAnimationTransitionController.h"
#import "LOTAnimationView.h" #import "LOTAnimationView.h"

1
Example/Tests/Switch.json Executable file

File diff suppressed because one or more lines are too long

View File

@ -64,6 +64,8 @@
622F77091F2BE63100269858 /* X.json in Resources */ = {isa = PBXBuildFile; fileRef = 622F76EB1F2BE63100269858 /* X.json */; }; 622F77091F2BE63100269858 /* X.json in Resources */ = {isa = PBXBuildFile; fileRef = 622F76EB1F2BE63100269858 /* X.json */; };
622F770A1F2BE63100269858 /* Y.json in Resources */ = {isa = PBXBuildFile; fileRef = 622F76EC1F2BE63100269858 /* Y.json */; }; 622F770A1F2BE63100269858 /* Y.json in Resources */ = {isa = PBXBuildFile; fileRef = 622F76EC1F2BE63100269858 /* Y.json */; };
622F770B1F2BE63100269858 /* Z.json in Resources */ = {isa = PBXBuildFile; fileRef = 622F76ED1F2BE63100269858 /* Z.json */; }; 622F770B1F2BE63100269858 /* Z.json in Resources */ = {isa = PBXBuildFile; fileRef = 622F76ED1F2BE63100269858 /* Z.json */; };
629EC57F1F54BFF1005B2C59 /* LAControlsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 629EC57E1F54BFF1005B2C59 /* LAControlsViewController.m */; };
629EC5811F54C00B005B2C59 /* Switch.json in Resources */ = {isa = PBXBuildFile; fileRef = 629EC5801F54C00B005B2C59 /* Switch.json */; };
62B2546A1E3A8D310035A842 /* LottieRootViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 62B254631E3A8D310035A842 /* LottieRootViewController.m */; }; 62B2546A1E3A8D310035A842 /* LottieRootViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 62B254631E3A8D310035A842 /* LottieRootViewController.m */; };
62B2546B1E3A8D310035A842 /* AnimationExplorerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 62B254651E3A8D310035A842 /* AnimationExplorerViewController.m */; }; 62B2546B1E3A8D310035A842 /* AnimationExplorerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 62B254651E3A8D310035A842 /* AnimationExplorerViewController.m */; };
62B2546C1E3A8D310035A842 /* AnimationTransitionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 62B254671E3A8D310035A842 /* AnimationTransitionViewController.m */; }; 62B2546C1E3A8D310035A842 /* AnimationTransitionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 62B254671E3A8D310035A842 /* AnimationTransitionViewController.m */; };
@ -166,6 +168,9 @@
622F76EC1F2BE63100269858 /* Y.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = Y.json; sourceTree = "<group>"; }; 622F76EC1F2BE63100269858 /* Y.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = Y.json; sourceTree = "<group>"; };
622F76ED1F2BE63100269858 /* Z.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = Z.json; sourceTree = "<group>"; }; 622F76ED1F2BE63100269858 /* Z.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = Z.json; sourceTree = "<group>"; };
62569CB2461B12ABC97FCB96 /* lottie-ios.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = "lottie-ios.podspec"; path = "../lottie-ios.podspec"; sourceTree = "<group>"; }; 62569CB2461B12ABC97FCB96 /* lottie-ios.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = "lottie-ios.podspec"; path = "../lottie-ios.podspec"; sourceTree = "<group>"; };
629EC57D1F54BFF1005B2C59 /* LAControlsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LAControlsViewController.h; sourceTree = "<group>"; };
629EC57E1F54BFF1005B2C59 /* LAControlsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LAControlsViewController.m; sourceTree = "<group>"; };
629EC5801F54C00B005B2C59 /* Switch.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = Switch.json; sourceTree = "<group>"; };
62B254621E3A8D310035A842 /* LottieRootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LottieRootViewController.h; sourceTree = "<group>"; }; 62B254621E3A8D310035A842 /* LottieRootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LottieRootViewController.h; sourceTree = "<group>"; };
62B254631E3A8D310035A842 /* LottieRootViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LottieRootViewController.m; sourceTree = "<group>"; }; 62B254631E3A8D310035A842 /* LottieRootViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LottieRootViewController.m; sourceTree = "<group>"; };
62B254641E3A8D310035A842 /* AnimationExplorerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnimationExplorerViewController.h; sourceTree = "<group>"; }; 62B254641E3A8D310035A842 /* AnimationExplorerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnimationExplorerViewController.h; sourceTree = "<group>"; };
@ -301,6 +306,8 @@
873B8AEA1B1F5CCA007FD442 /* Main.storyboard */, 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */,
62B254621E3A8D310035A842 /* LottieRootViewController.h */, 62B254621E3A8D310035A842 /* LottieRootViewController.h */,
62B254631E3A8D310035A842 /* LottieRootViewController.m */, 62B254631E3A8D310035A842 /* LottieRootViewController.m */,
629EC57D1F54BFF1005B2C59 /* LAControlsViewController.h */,
629EC57E1F54BFF1005B2C59 /* LAControlsViewController.m */,
62B254741E3A8D400035A842 /* Animation Explorer */, 62B254741E3A8D400035A842 /* Animation Explorer */,
62B254751E3A8D500035A842 /* Transition Demo */, 62B254751E3A8D500035A842 /* Transition Demo */,
62B254761E3A8D620035A842 /* Typing Animation Demo */, 62B254761E3A8D620035A842 /* Typing Animation Demo */,
@ -338,6 +345,7 @@
children = ( children = (
622F76CF1F2BE63100269858 /* TypeFace */, 622F76CF1F2BE63100269858 /* TypeFace */,
622F76B51F2BE58100269858 /* 9squares-AlBoardman.json */, 622F76B51F2BE58100269858 /* 9squares-AlBoardman.json */,
629EC5801F54C00B005B2C59 /* Switch.json */,
622F76B61F2BE58100269858 /* HamburgerArrow.json */, 622F76B61F2BE58100269858 /* HamburgerArrow.json */,
622F76B71F2BE58100269858 /* IconTransitions.json */, 622F76B71F2BE58100269858 /* IconTransitions.json */,
622F76B81F2BE58100269858 /* LottieLogo1_masked.json */, 622F76B81F2BE58100269858 /* LottieLogo1_masked.json */,
@ -596,6 +604,7 @@
622F76C61F2BE58100269858 /* LottieLogo1.json in Resources */, 622F76C61F2BE58100269858 /* LottieLogo1.json in Resources */,
622F77051F2BE63100269858 /* T.json in Resources */, 622F77051F2BE63100269858 /* T.json in Resources */,
622F77021F2BE63100269858 /* Q.json in Resources */, 622F77021F2BE63100269858 /* Q.json in Resources */,
629EC5811F54C00B005B2C59 /* Switch.json in Resources */,
622F76FB1F2BE63100269858 /* J.json in Resources */, 622F76FB1F2BE63100269858 /* J.json in Resources */,
622F77081F2BE63100269858 /* W.json in Resources */, 622F77081F2BE63100269858 /* W.json in Resources */,
622F76F61F2BE63100269858 /* E.json in Resources */, 622F76F61F2BE63100269858 /* E.json in Resources */,
@ -796,6 +805,7 @@
62B254731E3A8D3B0035A842 /* AnimatedTextField.m in Sources */, 62B254731E3A8D3B0035A842 /* AnimatedTextField.m in Sources */,
62B2546C1E3A8D310035A842 /* AnimationTransitionViewController.m in Sources */, 62B2546C1E3A8D310035A842 /* AnimationTransitionViewController.m in Sources */,
6003F59A195388D20070C39A /* main.m in Sources */, 6003F59A195388D20070C39A /* main.m in Sources */,
629EC57F1F54BFF1005B2C59 /* LAControlsViewController.m in Sources */,
BC7BF4841F37DA7300FB702C /* LottieFilesURL.m in Sources */, BC7BF4841F37DA7300FB702C /* LottieFilesURL.m in Sources */,
622F76451F2AAA6500269858 /* LAQRScannerViewController.m in Sources */, 622F76451F2AAA6500269858 /* LAQRScannerViewController.m in Sources */,
); );

View File

@ -0,0 +1,13 @@
//
// LAControlsViewController.h
// lottie-ios
//
// Created by brandon_withrow on 8/28/17.
// Copyright © 2017 Brandon Withrow. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface LAControlsViewController : UIViewController
@end

View File

@ -0,0 +1,62 @@
//
// LAControlsViewController.m
// lottie-ios
//
// Created by brandon_withrow on 8/28/17.
// Copyright © 2017 Brandon Withrow. All rights reserved.
//
#import "LAControlsViewController.h"
#import <Lottie/Lottie.h>
@interface LAControlsViewController ()
@end
@implementation LAControlsViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
UIButton *closeButton_ = [UIButton buttonWithType:UIButtonTypeSystem];
[closeButton_ setTitle:@"Close" forState:UIControlStateNormal];
[closeButton_ addTarget:self action:@selector(close) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:closeButton_];
CGSize buttonSize = [closeButton_ sizeThatFits:self.view.bounds.size];
closeButton_.frame = CGRectMake(10, 30, buttonSize.width, 50);
/// An animated toggle with different ON and OFF animations.
LOTAnimatedSwitch *toggle1 = [LOTAnimatedSwitch switchNamed:@"Switch"];
/// Off animation is 0 to 0.5 progress.
/// On animation is 0.5 to 1 progress.
[toggle1 setProgressRangeForOnState:0.5 toProgress:1];
[toggle1 setProgressRangeForOffState:0 toProgress:0.5];
[toggle1 addTarget:self action:@selector(switchToggled:) forControlEvents:UIControlEventValueChanged];
toggle1.center = CGPointMake(CGRectGetMidX(self.view.bounds), 90);
[self.view addSubview:toggle1];
/// An animated 'like' or 'heart' button.
/// Clicking toggles the Like or Heart state.
/// The animation runs from 0-1, progress 0 is off, progress 1 is on
LOTAnimatedSwitch *heartIcon = [LOTAnimatedSwitch switchNamed:@"TwitterHeart"];
heartIcon.bounds = CGRectMake(0, 0, 200, 200);
heartIcon.center = CGPointMake(CGRectGetMidX(self.view.bounds), CGRectGetMaxY(toggle1.frame) + (heartIcon.bounds.size.height * 0.5));
[heartIcon addTarget:self action:@selector(switchToggled:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:heartIcon];
}
- (void)switchToggled:(LOTAnimatedSwitch *)animatedSwitch {
NSLog(@"The switch is %@", (animatedSwitch.on ? @"ON" : @"OFF"));
}
- (void)close {
[self.presentingViewController dismissViewControllerAnimated:YES completion:NULL];
}
@end

View File

@ -66,7 +66,9 @@
@{@"name" : @"Animated Keyboard", @{@"name" : @"Animated Keyboard",
@"vc" : @"TypingDemoViewController"}, @"vc" : @"TypingDemoViewController"},
@{@"name" : @"Animated Transitions Demo", @{@"name" : @"Animated Transitions Demo",
@"vc" : @"AnimationTransitionViewController"}]; @"vc" : @"AnimationTransitionViewController"},
@{@"name" : @"Animated UIControls Demo",
@"vc" : @"LAControlsViewController"}];
} }
- (void)_playLottieAnimation { - (void)_playLottieAnimation {

View File

@ -196,6 +196,14 @@
628905431F352472005154FA /* LOTRadialGradientLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 628905401F352472005154FA /* LOTRadialGradientLayer.m */; }; 628905431F352472005154FA /* LOTRadialGradientLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 628905401F352472005154FA /* LOTRadialGradientLayer.m */; };
628905441F352472005154FA /* LOTRadialGradientLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 628905401F352472005154FA /* LOTRadialGradientLayer.m */; }; 628905441F352472005154FA /* LOTRadialGradientLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 628905401F352472005154FA /* LOTRadialGradientLayer.m */; };
628905451F352472005154FA /* LOTRadialGradientLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 628905401F352472005154FA /* LOTRadialGradientLayer.m */; }; 628905451F352472005154FA /* LOTRadialGradientLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 628905401F352472005154FA /* LOTRadialGradientLayer.m */; };
629EC52C1F50CBF7005B2C59 /* LOTAnimatedSwitch.h in Headers */ = {isa = PBXBuildFile; fileRef = 629EC52A1F50CBF7005B2C59 /* LOTAnimatedSwitch.h */; settings = {ATTRIBUTES = (Public, ); }; };
629EC52F1F50CC2E005B2C59 /* LOTAnimatedSwitch.m in Sources */ = {isa = PBXBuildFile; fileRef = 629EC52E1F50CC2E005B2C59 /* LOTAnimatedSwitch.m */; };
629EC5301F50CC39005B2C59 /* LOTAnimatedSwitch.m in Sources */ = {isa = PBXBuildFile; fileRef = 629EC52E1F50CC2E005B2C59 /* LOTAnimatedSwitch.m */; };
629EC5311F50CC53005B2C59 /* LOTAnimatedSwitch.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 629EC52A1F50CBF7005B2C59 /* LOTAnimatedSwitch.h */; };
629EC5341F50DFE4005B2C59 /* LOTAnimatedControl.h in Headers */ = {isa = PBXBuildFile; fileRef = 629EC5321F50DFE4005B2C59 /* LOTAnimatedControl.h */; settings = {ATTRIBUTES = (Public, ); }; };
629EC5371F50DFFF005B2C59 /* LOTAnimatedControl.m in Sources */ = {isa = PBXBuildFile; fileRef = 629EC5361F50DFFF005B2C59 /* LOTAnimatedControl.m */; };
629EC5381F50E00F005B2C59 /* LOTAnimatedControl.m in Sources */ = {isa = PBXBuildFile; fileRef = 629EC5361F50DFFF005B2C59 /* LOTAnimatedControl.m */; };
629EC5391F50E02A005B2C59 /* LOTAnimatedControl.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 629EC5321F50DFE4005B2C59 /* LOTAnimatedControl.h */; };
62BFC2DE1F14298D0068A342 /* LOTAnimatorNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 62BFC2D01F14298D0068A342 /* LOTAnimatorNode.h */; }; 62BFC2DE1F14298D0068A342 /* LOTAnimatorNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 62BFC2D01F14298D0068A342 /* LOTAnimatorNode.h */; };
62BFC2DF1F14298D0068A342 /* LOTAnimatorNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 62BFC2D01F14298D0068A342 /* LOTAnimatorNode.h */; }; 62BFC2DF1F14298D0068A342 /* LOTAnimatorNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 62BFC2D01F14298D0068A342 /* LOTAnimatorNode.h */; };
62BFC2E01F14298D0068A342 /* LOTAnimatorNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 62BFC2D11F14298D0068A342 /* LOTAnimatorNode.m */; }; 62BFC2E01F14298D0068A342 /* LOTAnimatorNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 62BFC2D11F14298D0068A342 /* LOTAnimatorNode.m */; };
@ -292,6 +300,8 @@
dstPath = include/Lottie; dstPath = include/Lottie;
dstSubfolderSpec = 16; dstSubfolderSpec = 16;
files = ( files = (
629EC5391F50E02A005B2C59 /* LOTAnimatedControl.h in CopyFiles */,
629EC5311F50CC53005B2C59 /* LOTAnimatedSwitch.h in CopyFiles */,
6289053E1F33EA0F005154FA /* LOTCacheProvider.h in CopyFiles */, 6289053E1F33EA0F005154FA /* LOTCacheProvider.h in CopyFiles */,
62E27B481F3115A00098420E /* LOTAnimationCache.h in CopyFiles */, 62E27B481F3115A00098420E /* LOTAnimationCache.h in CopyFiles */,
622F77141F2BF6BE00269858 /* LOTComposition.h in CopyFiles */, 622F77141F2BF6BE00269858 /* LOTComposition.h in CopyFiles */,
@ -390,6 +400,10 @@
6274D0201F1E830E00E05049 /* LOTTransformInterpolator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = LOTTransformInterpolator.m; path = "lottie-ios/Classes/RenderSystem/InterpolatorNodes/LOTTransformInterpolator.m"; sourceTree = SOURCE_ROOT; }; 6274D0201F1E830E00E05049 /* LOTTransformInterpolator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = LOTTransformInterpolator.m; path = "lottie-ios/Classes/RenderSystem/InterpolatorNodes/LOTTransformInterpolator.m"; sourceTree = SOURCE_ROOT; };
6289053F1F352472005154FA /* LOTRadialGradientLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LOTRadialGradientLayer.h; sourceTree = "<group>"; }; 6289053F1F352472005154FA /* LOTRadialGradientLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LOTRadialGradientLayer.h; sourceTree = "<group>"; };
628905401F352472005154FA /* LOTRadialGradientLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LOTRadialGradientLayer.m; sourceTree = "<group>"; }; 628905401F352472005154FA /* LOTRadialGradientLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LOTRadialGradientLayer.m; sourceTree = "<group>"; };
629EC52A1F50CBF7005B2C59 /* LOTAnimatedSwitch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LOTAnimatedSwitch.h; sourceTree = "<group>"; };
629EC52E1F50CC2E005B2C59 /* LOTAnimatedSwitch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LOTAnimatedSwitch.m; sourceTree = "<group>"; };
629EC5321F50DFE4005B2C59 /* LOTAnimatedControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LOTAnimatedControl.h; sourceTree = "<group>"; };
629EC5361F50DFFF005B2C59 /* LOTAnimatedControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LOTAnimatedControl.m; sourceTree = "<group>"; };
62BFC2D01F14298D0068A342 /* LOTAnimatorNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LOTAnimatorNode.h; path = "lottie-ios/Classes/RenderSystem/LOTAnimatorNode.h"; sourceTree = SOURCE_ROOT; }; 62BFC2D01F14298D0068A342 /* LOTAnimatorNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LOTAnimatorNode.h; path = "lottie-ios/Classes/RenderSystem/LOTAnimatorNode.h"; sourceTree = SOURCE_ROOT; };
62BFC2D11F14298D0068A342 /* LOTAnimatorNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = LOTAnimatorNode.m; path = "lottie-ios/Classes/RenderSystem/LOTAnimatorNode.m"; sourceTree = SOURCE_ROOT; }; 62BFC2D11F14298D0068A342 /* LOTAnimatorNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = LOTAnimatorNode.m; path = "lottie-ios/Classes/RenderSystem/LOTAnimatorNode.m"; sourceTree = SOURCE_ROOT; };
62BFC2D21F14298D0068A342 /* LOTFillRenderer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LOTFillRenderer.h; path = "lottie-ios/Classes/RenderSystem/RenderNodes/LOTFillRenderer.h"; sourceTree = SOURCE_ROOT; }; 62BFC2D21F14298D0068A342 /* LOTFillRenderer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LOTFillRenderer.h; path = "lottie-ios/Classes/RenderSystem/RenderNodes/LOTFillRenderer.h"; sourceTree = SOURCE_ROOT; };
@ -538,6 +552,8 @@
481A4A571E4A7885003CF62B /* Private */ = { 481A4A571E4A7885003CF62B /* Private */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
629EC5361F50DFFF005B2C59 /* LOTAnimatedControl.m */,
629EC52E1F50CC2E005B2C59 /* LOTAnimatedSwitch.m */,
EE498E3B1F336A3B00D1DFCD /* LOTCacheProvider.m */, EE498E3B1F336A3B00D1DFCD /* LOTCacheProvider.m */,
62E27B491F3115AF0098420E /* LOTAnimationCache.m */, 62E27B491F3115AF0098420E /* LOTAnimationCache.m */,
622F77101F2BF6AA00269858 /* LOTComposition.m */, 622F77101F2BF6AA00269858 /* LOTComposition.m */,
@ -683,10 +699,12 @@
children = ( children = (
EE498E3D1F336A4900D1DFCD /* LOTCacheProvider.h */, EE498E3D1F336A4900D1DFCD /* LOTCacheProvider.h */,
62E27B451F31158B0098420E /* LOTAnimationCache.h */, 62E27B451F31158B0098420E /* LOTAnimationCache.h */,
2DBA16351B4FA408937A16CE /* LOTAnimationView_Compat.h */,
622F770D1F2BF6A000269858 /* LOTComposition.h */, 622F770D1F2BF6A000269858 /* LOTComposition.h */,
FA1F5A9F1E42B52800FF36BF /* LOTAnimationView.h */, FA1F5A9F1E42B52800FF36BF /* LOTAnimationView.h */,
62CA59C41E3C179F002D7188 /* LOTAnimationTransitionController.h */, 62CA59C41E3C179F002D7188 /* LOTAnimationTransitionController.h */,
2DBA16351B4FA408937A16CE /* LOTAnimationView_Compat.h */, 629EC52A1F50CBF7005B2C59 /* LOTAnimatedSwitch.h */,
629EC5321F50DFE4005B2C59 /* LOTAnimatedControl.h */,
62CA59C61E3C179F002D7188 /* Lottie.h */, 62CA59C61E3C179F002D7188 /* Lottie.h */,
); );
name = PublicHeaders; name = PublicHeaders;
@ -735,6 +753,7 @@
62BFC2FC1F14298D0068A342 /* LOTValueInterpolator.h in Headers */, 62BFC2FC1F14298D0068A342 /* LOTValueInterpolator.h in Headers */,
6274D0211F1E830E00E05049 /* LOTTransformInterpolator.h in Headers */, 6274D0211F1E830E00E05049 /* LOTTransformInterpolator.h in Headers */,
481A4AC91E4A7885003CF62B /* LOTShapeTransform.h in Headers */, 481A4AC91E4A7885003CF62B /* LOTShapeTransform.h in Headers */,
629EC52C1F50CBF7005B2C59 /* LOTAnimatedSwitch.h in Headers */,
6274CF8B1F16F29200E05049 /* LOTPointInterpolator.h in Headers */, 6274CF8B1F16F29200E05049 /* LOTPointInterpolator.h in Headers */,
622F762C1F2A8CBA00269858 /* LOTShapeStar.h in Headers */, 622F762C1F2A8CBA00269858 /* LOTShapeStar.h in Headers */,
622F76641F2BCA7700269858 /* LOTShapeRepeater.h in Headers */, 622F76641F2BCA7700269858 /* LOTShapeRepeater.h in Headers */,
@ -751,6 +770,7 @@
62BFC3031F1449380068A342 /* LOTBezierData.h in Headers */, 62BFC3031F1449380068A342 /* LOTBezierData.h in Headers */,
62BFC2ED1F14298D0068A342 /* LOTPathAnimator.h in Headers */, 62BFC2ED1F14298D0068A342 /* LOTPathAnimator.h in Headers */,
484EBA161E565AF700D4CAD9 /* LOTAsset.h in Headers */, 484EBA161E565AF700D4CAD9 /* LOTAsset.h in Headers */,
629EC5341F50DFE4005B2C59 /* LOTAnimatedControl.h in Headers */,
481A4AAB1E4A7885003CF62B /* LOTMask.h in Headers */, 481A4AAB1E4A7885003CF62B /* LOTMask.h in Headers */,
622F764E1F2AC1BF00269858 /* LOTArrayInterpolator.h in Headers */, 622F764E1F2AC1BF00269858 /* LOTArrayInterpolator.h in Headers */,
6274CFA01F17E94C00E05049 /* LOTPathInterpolator.h in Headers */, 6274CFA01F17E94C00E05049 /* LOTPathInterpolator.h in Headers */,
@ -957,9 +977,11 @@
481A4AB71E4A7885003CF62B /* LOTShapeFill.m in Sources */, 481A4AB71E4A7885003CF62B /* LOTShapeFill.m in Sources */,
62C9EA451F1FDBF000DE7D07 /* LOTCircleAnimator.m in Sources */, 62C9EA451F1FDBF000DE7D07 /* LOTCircleAnimator.m in Sources */,
622F76501F2AC1BF00269858 /* LOTArrayInterpolator.m in Sources */, 622F76501F2AC1BF00269858 /* LOTArrayInterpolator.m in Sources */,
629EC5371F50DFFF005B2C59 /* LOTAnimatedControl.m in Sources */,
6201FAE81F200B4A00A047C9 /* LOTMaskContainer.m in Sources */, 6201FAE81F200B4A00A047C9 /* LOTMaskContainer.m in Sources */,
481A4AC31E4A7885003CF62B /* LOTShapeRectangle.m in Sources */, 481A4AC31E4A7885003CF62B /* LOTShapeRectangle.m in Sources */,
481A4AD11E4A7885003CF62B /* LOTAnimationTransitionController.m in Sources */, 481A4AD11E4A7885003CF62B /* LOTAnimationTransitionController.m in Sources */,
629EC52F1F50CC2E005B2C59 /* LOTAnimatedSwitch.m in Sources */,
62C9EA261F1EB49000DE7D07 /* LOTCompositionContainer.m in Sources */, 62C9EA261F1EB49000DE7D07 /* LOTCompositionContainer.m in Sources */,
622F766D1F2BCE1300269858 /* LOTRepeaterRenderer.m in Sources */, 622F766D1F2BCE1300269858 /* LOTRepeaterRenderer.m in Sources */,
622F76371F2A91CA00269858 /* LOTPolystarAnimator.m in Sources */, 622F76371F2A91CA00269858 /* LOTPolystarAnimator.m in Sources */,
@ -1015,9 +1037,11 @@
62C9EA471F1FDBF000DE7D07 /* LOTCircleAnimator.m in Sources */, 62C9EA471F1FDBF000DE7D07 /* LOTCircleAnimator.m in Sources */,
622F76521F2AC1BF00269858 /* LOTArrayInterpolator.m in Sources */, 622F76521F2AC1BF00269858 /* LOTArrayInterpolator.m in Sources */,
6201FAEA1F200B4A00A047C9 /* LOTMaskContainer.m in Sources */, 6201FAEA1F200B4A00A047C9 /* LOTMaskContainer.m in Sources */,
629EC5381F50E00F005B2C59 /* LOTAnimatedControl.m in Sources */,
62C9EA281F1EB49000DE7D07 /* LOTCompositionContainer.m in Sources */, 62C9EA281F1EB49000DE7D07 /* LOTCompositionContainer.m in Sources */,
622F766F1F2BCE1300269858 /* LOTRepeaterRenderer.m in Sources */, 622F766F1F2BCE1300269858 /* LOTRepeaterRenderer.m in Sources */,
622F76391F2A91CA00269858 /* LOTPolystarAnimator.m in Sources */, 622F76391F2A91CA00269858 /* LOTPolystarAnimator.m in Sources */,
629EC5301F50CC39005B2C59 /* LOTAnimatedSwitch.m in Sources */,
6274CF8F1F16F29200E05049 /* LOTPointInterpolator.m in Sources */, 6274CF8F1F16F29200E05049 /* LOTPointInterpolator.m in Sources */,
6274CF9D1F17E92F00E05049 /* LOTSizeInterpolator.m in Sources */, 6274CF9D1F17E92F00E05049 /* LOTSizeInterpolator.m in Sources */,
62BFC2E71F14298D0068A342 /* LOTFillRenderer.m in Sources */, 62BFC2E71F14298D0068A342 /* LOTFillRenderer.m in Sources */,

View File

@ -30,7 +30,11 @@ For the first time, designers can create and ship beautiful animations without a
s.osx.exclude_files = ['lottie-ios/Classes/PublicHeaders/LOTAnimationTransitionController.h', s.osx.exclude_files = ['lottie-ios/Classes/PublicHeaders/LOTAnimationTransitionController.h',
'lottie-ios/Classes/Private/LOTAnimationTransitionController.m', 'lottie-ios/Classes/Private/LOTAnimationTransitionController.m',
'lottie-ios/Classes/PublicHeaders/LOTCacheProvider.h', 'lottie-ios/Classes/PublicHeaders/LOTCacheProvider.h',
'lottie-ios/Classes/Private/LOTCacheProvider.m'] 'lottie-ios/Classes/Private/LOTCacheProvider.m',
'lottie-ios/Classes/PublicHeaders/LOTAnimatedSwitch.h',
'lottie-ios/Classes/Private/LOTAnimatedSwitch.m',
'lottie-ios/Classes/PublicHeaders/LOTAnimatedControl.h',
'lottie-ios/Classes/Private/LOTAnimatedControl.m']
# s.resource_bundles = { # s.resource_bundles = {
# 'lottie-ios' => ['lottie-ios/Assets/*.png'] # 'lottie-ios' => ['lottie-ios/Assets/*.png']
# } # }

View File

@ -24,4 +24,7 @@
fromLayer:(CALayer *_Nonnull)fromlayer fromLayer:(CALayer *_Nonnull)fromlayer
toLayerNamed:(NSString *_Nonnull)layerName; toLayerNamed:(NSString *_Nonnull)layerName;
@property (nonatomic, readonly, nonnull) NSArray<LOTLayerContainer *> *childLayers;
@property (nonatomic, readonly, nonnull) NSDictionary *childMap;
@end @end

View File

@ -12,7 +12,6 @@
#import "LOTHelpers.h" #import "LOTHelpers.h"
@implementation LOTCompositionContainer { @implementation LOTCompositionContainer {
NSArray<LOTLayerContainer *> *_childLayers;
NSNumber *_frameOffset; NSNumber *_frameOffset;
CALayer *DEBUG_Center; CALayer *DEBUG_Center;
} }
@ -44,6 +43,7 @@
- (void)intializeWithChildGroup:(LOTLayerGroup *)childGroup - (void)intializeWithChildGroup:(LOTLayerGroup *)childGroup
withAssetGroup:(LOTAssetGroup *)assetGroup { withAssetGroup:(LOTAssetGroup *)assetGroup {
NSMutableDictionary *childMap = [NSMutableDictionary dictionary];
NSMutableArray *children = [NSMutableArray array]; NSMutableArray *children = [NSMutableArray array];
NSArray *reversedItems = [[childGroup.layers reverseObjectEnumerator] allObjects]; NSArray *reversedItems = [[childGroup.layers reverseObjectEnumerator] allObjects];
@ -73,7 +73,11 @@
[self.wrapperLayer addSublayer:child]; [self.wrapperLayer addSublayer:child];
} }
[children addObject:child]; [children addObject:child];
if (child.layerName) {
[childMap setObject:child forKey:child.layerName];
} }
}
_childMap = childMap;
_childLayers = children; _childLayers = children;
} }
@ -115,15 +119,14 @@
} }
} }
} }
return NO; return NO;
} }
- (void)addSublayer:(nonnull CALayer *)subLayer - (void)addSublayer:(nonnull CALayer *)subLayer
toLayerNamed:(nonnull NSString *)layerName toLayerNamed:(nonnull NSString *)layerName
applyTransform:(BOOL)applyTransform { applyTransform:(BOOL)applyTransform {
for (LOTLayerContainer *child in _childLayers) { LOTLayerContainer *child = _childMap[layerName];
if ([child.layerName isEqualToString:layerName]) { if (child) {
if (applyTransform) { if (applyTransform) {
[child addAndMaskSublayer:subLayer]; [child addAndMaskSublayer:subLayer];
} else { } else {
@ -135,17 +138,15 @@
} }
} }
} }
}
- (CGRect)convertRect:(CGRect)rect - (CGRect)convertRect:(CGRect)rect
fromLayer:(CALayer *_Nonnull)fromlayer fromLayer:(CALayer *_Nonnull)fromlayer
toLayerNamed:(NSString *_Nonnull)layerName { toLayerNamed:(NSString *_Nonnull)layerName {
CGRect xRect = rect; CGRect xRect = rect;
for (LOTLayerContainer *child in _childLayers) { LOTLayerContainer *child = _childMap[layerName];
if ([child.layerName isEqualToString:layerName]) { if (child) {
xRect = [fromlayer convertRect:rect toLayer:child]; xRect = [fromlayer convertRect:rect toLayer:child];
} }
}
return xRect; return xRect;
} }

View File

@ -0,0 +1,119 @@
//
// LOTAnimatedControl.m
// Lottie
//
// Created by brandon_withrow on 8/25/17.
// Copyright © 2017 Airbnb. All rights reserved.
//
#import "LOTAnimatedControl.h"
#import "LOTAnimationView_Internal.h"
@implementation LOTAnimatedControl {
UIControlState _priorState;
NSMutableDictionary *_layerMap;
}
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
_animationView = [[LOTAnimationView alloc] init];
_animationView.contentMode = UIViewContentModeScaleAspectFit;
_animationView.userInteractionEnabled = NO;
[self addSubview:_animationView];
_layerMap = [NSMutableDictionary dictionary];
}
return self;
}
- (LOTComposition *)animationComp {
return _animationView.sceneModel;
}
- (void)setAnimationComp:(LOTComposition *)animationComp {
[_animationView setSceneModel:animationComp];
[self checkStateChangedAndUpdate:YES];
}
- (void)setLayerName:(NSString * _Nonnull)layerName forState:(UIControlState)state {
_layerMap[@(state)] = layerName;
[self checkStateChangedAndUpdate:YES];
}
#pragma mark - Setter Overrides
- (void)setEnabled:(BOOL)enabled {
_priorState = self.state;
[super setEnabled:enabled];
[self checkStateChangedAndUpdate:NO];
}
- (void)setSelected:(BOOL)selected {
_priorState = self.state;
[super setSelected:selected];
[self checkStateChangedAndUpdate:NO];
}
- (void)setHighlighted:(BOOL)highlighted {
_priorState = self.state;
[super setHighlighted:highlighted];
[self checkStateChangedAndUpdate:NO];
}
- (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event {
_priorState = self.state;
[super touchesBegan:touches withEvent:event];
[self checkStateChangedAndUpdate:NO];
}
- (void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event {
_priorState = self.state;
[super touchesMoved:touches withEvent:event];
[self checkStateChangedAndUpdate:NO];
}
- (void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event {
_priorState = self.state;
[super touchesEnded:touches withEvent:event];
[self checkStateChangedAndUpdate:NO];
}
- (void)touchesCancelled:(NSSet*)touches withEvent:(UIEvent*)event {
_priorState = self.state;
[super touchesCancelled:touches withEvent:event];
[self checkStateChangedAndUpdate:NO];
}
- (CGSize)intrinsicContentSize {
return _animationView.intrinsicContentSize;
}
- (void)layoutSubviews {
[super layoutSubviews];
_animationView.frame = self.bounds;
}
#pragma mark - Private interface implementation
- (void)checkStateChangedAndUpdate:(BOOL)forceUpdate {
if(self.state == _priorState && !forceUpdate) {
return;
}
_priorState = self.state;
NSString *name = _layerMap[@(self.state)];
if (!name) {
return;
}
CALayer *layer = [_animationView layerForKey:name];
if (!layer) {
return;
}
for (CALayer *child in [_animationView compositionLayers]) {
child.hidden = YES;
}
layer.hidden = NO;
}
@end

View File

@ -0,0 +1,101 @@
//
// LOTAnimatedSwitch.m
// Lottie
//
// Created by brandon_withrow on 8/25/17.
// Copyright © 2017 Airbnb. All rights reserved.
//
#import "LOTAnimatedSwitch.h"
#import "LOTAnimationView.h"
#import "CGGeometry+LOTAdditions.h"
@implementation LOTAnimatedSwitch {
CGFloat _onStartProgress;
CGFloat _onEndProgress;
CGFloat _offStartProgress;
CGFloat _offEndProgress;
BOOL _on;
}
/// Convenience method to initialize a control from the Main Bundle by name
+ (instancetype _Nonnull )switchNamed:(NSString * _Nonnull)toggleName {
return [LOTAnimatedSwitch switchNamed:toggleName inBundle:[NSBundle mainBundle]];
}
/// Convenience method to initialize a control from the specified bundle by name
+ (instancetype _Nonnull )switchNamed:(NSString * _Nonnull)toggleName inBundle:(NSBundle * _Nonnull)bundle {
LOTComposition *composition = [LOTComposition animationNamed:toggleName inBundle:bundle];
LOTAnimatedSwitch *animatedControl = [[LOTAnimatedSwitch alloc] initWithFrame:CGRectZero];
if (composition) {
[animatedControl setAnimationComp:composition];
animatedControl.bounds = composition.compBounds;
}
return animatedControl;
}
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
_onStartProgress = 0;
_onEndProgress = 1;
_offStartProgress = 1;
_offEndProgress = 0;
_on = NO;
[self addTarget:self action:@selector(_toggle) forControlEvents:UIControlEventTouchUpInside];
}
return self;
}
- (void)setAnimationComp:(LOTComposition *)animationComp {
[super setAnimationComp:animationComp];
[self setOn:_on animated:NO];
}
#pragma mark - External Methods
- (void)setProgressRangeForOnState:(CGFloat)fromProgress toProgress:(CGFloat)toProgress {
_onStartProgress = fromProgress;
_onEndProgress = toProgress;
[self setOn:_on animated:NO];
}
- (void)setProgressRangeForOffState:(CGFloat)fromProgress toProgress:(CGFloat)toProgress {
_offStartProgress = fromProgress;
_offEndProgress = toProgress;
[self setOn:_on animated:NO];
}
- (void)setOn:(BOOL)on {
[self setOn:on animated:NO];
}
- (void)setOn:(BOOL)on animated:(BOOL)animated {
if (_on == on) {
animated = NO;
}
_on = on;
CGFloat startProgress = on ? _onStartProgress : _offStartProgress;
CGFloat endProgress = on ? _onEndProgress : _offEndProgress;
if (animated) {
[self.animationView pause];
[self.animationView playFromProgress:startProgress toProgress:endProgress withCompletion:nil];
} else {
self.animationView.animationProgress = endProgress;
}
}
#pragma mark - Internal Methods
- (void)_toggle {
if (self.isEnabled) {
[self setOn:!_on animated:YES];
[self sendActionsForControlEvents:UIControlEventValueChanged];
}
}
@end

View File

@ -99,6 +99,14 @@ static NSString * const kCompContainerAnimationKey = @"play";
return self; return self;
} }
- (instancetype)init {
self = [super init];
if (self) {
[self _commonInit];
}
return self;
}
# pragma mark - Internal Methods # pragma mark - Internal Methods
#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR #if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
@ -401,7 +409,6 @@ static NSString * const kCompContainerAnimationKey = @"play";
#endif #endif
- (CGRect)convertRect:(CGRect)rect - (CGRect)convertRect:(CGRect)rect
toLayerNamed:(NSString *_Nullable)layerName { toLayerNamed:(NSString *_Nullable)layerName {
[self _layout]; [self _layout];
@ -430,6 +437,16 @@ static NSString * const kCompContainerAnimationKey = @"play";
[_compContainer logHierarchyKeypathsWithParent:nil]; [_compContainer logHierarchyKeypathsWithParent:nil];
} }
# pragma mark - Semi-Private Methods
- (CALayer * _Nullable)layerForKey:(NSString * _Nonnull)keyname {
return _compContainer.childMap[keyname];
}
- (NSArray * _Nonnull)compositionLayers {
return _compContainer.childLayers;
}
# pragma mark - Getters and Setters # pragma mark - Getters and Setters
- (CGFloat)animationDuration { - (CGFloat)animationDuration {
@ -471,6 +488,13 @@ static NSString * const kCompContainerAnimationKey = @"play";
#define LOTViewContentModeBottomLeft UIViewContentModeBottomLeft #define LOTViewContentModeBottomLeft UIViewContentModeBottomLeft
#define LOTViewContentModeBottomRight UIViewContentModeBottomRight #define LOTViewContentModeBottomRight UIViewContentModeBottomRight
- (CGSize)intrinsicContentSize {
if (!_sceneModel) {
return CGSizeMake(UIViewNoIntrinsicMetric, UIViewNoIntrinsicMetric);
}
return _sceneModel.compBounds.size;
}
- (void)didMoveToSuperview { - (void)didMoveToSuperview {
[super didMoveToSuperview]; [super didMoveToSuperview];
if (self.superview == nil) { if (self.superview == nil) {
@ -525,10 +549,6 @@ static NSString * const kCompContainerAnimationKey = @"play";
#endif #endif
- (CGSize)intrinsicContentSize {
return _sceneModel.compBounds.size;
}
- (void)_layout { - (void)_layout {
CGPoint centerPoint = LOT_RectGetCenterPoint(self.bounds); CGPoint centerPoint = LOT_RectGetCenterPoint(self.bounds);
CATransform3D xform; CATransform3D xform;

View File

@ -16,4 +16,7 @@ typedef enum : NSUInteger {
@interface LOTAnimationView () <CAAnimationDelegate> @interface LOTAnimationView () <CAAnimationDelegate>
- (CALayer * _Nullable)layerForKey:(NSString * _Nonnull)keyname;
- (NSArray * _Nonnull)compositionLayers;
@end @end

View File

@ -0,0 +1,28 @@
//
// LOTAnimatedControl.h
// Lottie
//
// Created by brandon_withrow on 8/25/17.
// Copyright © 2017 Airbnb. All rights reserved.
//
#import <UIKit/UIKit.h>
@class LOTAnimationView;
@class LOTComposition;
@interface LOTAnimatedControl : UIControl
// This class is a base class that is intended to be subclassed
/**
* Map a specific animation layer to a control state.
* When the state is set all layers will be hidden except the specified layer.
**/
- (void)setLayerName:(NSString * _Nonnull)layerName forState:(UIControlState)state;
@property (nonatomic, readonly, nonnull) LOTAnimationView *animationView;
@property (nonatomic, nullable) LOTComposition *animationComp;
@end

View File

@ -0,0 +1,50 @@
//
// LOTAnimatedSwitch.h
// Lottie
//
// Created by brandon_withrow on 8/25/17.
// Copyright © 2017 Airbnb. All rights reserved.
//
#import "LOTAnimatedControl.h"
NS_ASSUME_NONNULL_BEGIN
@interface LOTAnimatedSwitch : LOTAnimatedControl
/// Convenience method to initialize a control from the Main Bundle by name
+ (instancetype _Nonnull )switchNamed:(NSString * _Nonnull)toggleName;
/// Convenience method to initialize a control from the specified bundle by name
+ (instancetype _Nonnull )switchNamed:(NSString * _Nonnull)toggleName inBundle:(NSBundle * _Nonnull)bundle;
/// The ON/OFF state of the control. Setting will toggle without animation
@property (nonatomic, getter=isOn) BOOL on;
/// Set the state of the control with animation
- (void)setOn:(BOOL)on animated:(BOOL)animated; // does not send action
/// Styling
/**
* Sets the animation play range for the ON state animation.
* fromProgress is the start of the animation
* toProgress is the end of the animation and also the ON static state
* Defaults 0-1
**/
- (void)setProgressRangeForOnState:(CGFloat)fromProgress
toProgress:(CGFloat)toProgress NS_SWIFT_NAME(setProgressRangeForOnState(fromProgress:toProgress:));
/**
* Sets the animation play range for the OFF state animation.
* fromProgress is the start of the animation
* toProgress is the end of the animation and also the OFF static state
* Defaults 1-0
**/
- (void)setProgressRangeForOffState:(CGFloat)fromProgress
toProgress:(CGFloat)toProgress NS_SWIFT_NAME(setProgressRangeForOffState(fromProgress:toProgress:));
@end
NS_ASSUME_NONNULL_END

View File

@ -25,6 +25,8 @@ FOUNDATION_EXPORT const unsigned char LottieVersionString[];
#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR #if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
#import "LOTAnimationTransitionController.h" #import "LOTAnimationTransitionController.h"
#import "LOTAnimatedSwitch.h"
#import "LOTAnimatedControl.h"
#endif #endif
#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR #if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR