Added time progress, started building masks

This commit is contained in:
Brandon Withrow
2016-07-22 16:06:51 -07:00
parent af697b6fa0
commit aa17a9dede
19 changed files with 203 additions and 107 deletions

View File

@@ -85,6 +85,7 @@
62FE40EC1D402C0200CA389D /* parentTest.json in Resources */ = {isa = PBXBuildFile; fileRef = 62FE40EB1D402C0200CA389D /* parentTest.json */; };
62FE41161D41526D00CA389D /* InOutAnimation.json in Resources */ = {isa = PBXBuildFile; fileRef = 62FE41151D41526D00CA389D /* InOutAnimation.json */; };
62FE41431D41862200CA389D /* LAAnimatableLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 62FE41421D41862200CA389D /* LAAnimatableLayer.m */; };
62FE41BC1D42DD8500CA389D /* LAMaskLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 62FE41BB1D42DD8500CA389D /* LAMaskLayer.m */; };
F5B4E946F7B28B4594824641 /* libPods-LotteAnimator.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BC68632413866F85CEACB7EA /* libPods-LotteAnimator.a */; };
/* End PBXBuildFile section */
@@ -203,6 +204,8 @@
62FE41151D41526D00CA389D /* InOutAnimation.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = InOutAnimation.json; sourceTree = "<group>"; };
62FE41411D41862200CA389D /* LAAnimatableLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LAAnimatableLayer.h; sourceTree = "<group>"; };
62FE41421D41862200CA389D /* LAAnimatableLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LAAnimatableLayer.m; sourceTree = "<group>"; };
62FE41BA1D42DD8500CA389D /* LAMaskLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LAMaskLayer.h; sourceTree = "<group>"; };
62FE41BB1D42DD8500CA389D /* LAMaskLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LAMaskLayer.m; sourceTree = "<group>"; };
AEE1A33E4CE2F6024DE7793E /* Pods-LotteAnimator.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-LotteAnimator.debug.xcconfig"; path = "Pods/Target Support Files/Pods-LotteAnimator/Pods-LotteAnimator.debug.xcconfig"; sourceTree = "<group>"; };
BC68632413866F85CEACB7EA /* libPods-LotteAnimator.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-LotteAnimator.a"; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
@@ -258,6 +261,8 @@
62FE41421D41862200CA389D /* LAAnimatableLayer.m */,
4804B32A1C1F835F00DA8AF7 /* LALayerView.h */,
4804B32B1C1F835F00DA8AF7 /* LALayerView.m */,
62FE41BA1D42DD8500CA389D /* LAMaskLayer.h */,
62FE41BB1D42DD8500CA389D /* LAMaskLayer.m */,
620CD7E31D38180800055AD1 /* LAGroupLayerView.h */,
620CD7E41D38180800055AD1 /* LAGroupLayerView.m */,
486BE04C1D36F1BE00CD14A0 /* LAShapeLayerView.h */,
@@ -608,6 +613,7 @@
620CD7CD1D3415F000055AD1 /* LAAnimatableRectValue.m in Sources */,
620A565C1D1C81610030EBFB /* LAAnimatableColorValue.m in Sources */,
48372A5E1C209A8900AD0293 /* LAShapeTransform.m in Sources */,
62FE41BC1D42DD8500CA389D /* LAMaskLayer.m in Sources */,
620CD7D01D343A2500055AD1 /* LAAnimatableScaleValue.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;

View File

@@ -45,22 +45,6 @@
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "LotteAnimator/LAAnimatableColorValue.m"
timestampString = "490830150.413192"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "152"
endingLineNumber = "152"
landmarkName = "-_colorValueFromArray:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
@@ -77,22 +61,6 @@
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "LotteAnimator/LAShapePath.m"
timestampString = "490659641.355334"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "23"
endingLineNumber = "23"
landmarkName = "-_mapFromJSON:frameRate:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
@@ -131,13 +99,13 @@
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "LotteAnimator/LALayer.m"
timestampString = "490825912.611288"
filePath = "LotteAnimator/LAAnimatableLayer.m"
timestampString = "490920717.958644"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "94"
endingLineNumber = "94"
landmarkName = "-_mapFromJSON:fromComposition:"
startingLineNumber = "56"
endingLineNumber = "56"
landmarkName = "-setAnimationProgress:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
@@ -147,13 +115,45 @@
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "LotteAnimator/LAAnimatableLayer.m"
timestampString = "490837507.04002"
filePath = "LotteAnimator/LALayerView.m"
timestampString = "490921111.145475"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "48"
endingLineNumber = "48"
landmarkName = "-setAnimationProgress:"
startingLineNumber = "128"
endingLineNumber = "128"
landmarkName = "-_setupViewFromModel"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "LotteAnimator/CAAnimationGroup+LAAnimatableGroup.m"
timestampString = "490920346.033008"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "14"
endingLineNumber = "14"
landmarkName = "+animationGroupForAnimatablePropertiesWithKeyPaths:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "LotteAnimator/CAAnimationGroup+LAAnimatableGroup.m"
timestampString = "490920366.856974"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "29"
endingLineNumber = "29"
landmarkName = "+animationGroupForAnimatablePropertiesWithKeyPaths:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>

View File

@@ -10,17 +10,17 @@
@implementation CAAnimationGroup (LAAnimatableGroup)
+ (nullable CAAnimationGroup *)animationGroupForAnimatablePropertiesWithKeyPaths:(nonnull NSDictionary<NSString *, id<LAAnimatableValue>> *)properties; {
+ (nullable CAAnimationGroup *)animationGroupForAnimatablePropertiesWithKeyPaths:(nonnull NSDictionary<NSString *, id<LAAnimatableValue>> *)properties {
NSMutableArray *animations = [NSMutableArray array];
NSTimeInterval duration = 0;
NSTimeInterval animduration = 0;
for (NSString *keyPath in properties.allKeys) {
id <LAAnimatableValue>property = properties[keyPath];
if ([property hasAnimation]) {
CAKeyframeAnimation *animation = [property animationForKeyPath:keyPath];
[animations addObject:animation];
if (animation.duration + animation.beginTime > duration) {
duration = animation.duration + animation.beginTime;
if (animation.duration + animation.beginTime > animduration) {
animduration = animation.duration + animation.beginTime;
}
}
}
@@ -28,7 +28,7 @@
if (animations.count) {
CAAnimationGroup *animation = [CAAnimationGroup new];
animation.animations = animations;
animation.duration = duration;
animation.duration = animduration;
animation.fillMode = kCAFillModeForwards;
animation.removedOnCompletion = NO;
return animation;

View File

@@ -10,8 +10,11 @@
@interface LAAnimatableLayer : CALayer
- (instancetype)initWithDuration:(NSTimeInterval)duration NS_DESIGNATED_INITIALIZER;
@property (nonatomic, strong) NSArray *animationSublayers;
@property (nonatomic, strong) NSArray<LAAnimatableLayer *> *childLayers;
@property (nonatomic, readonly) NSTimeInterval laAnimationDuration;
@property (nonatomic, assign) BOOL loopAnimation;
@property (nonatomic, assign) BOOL autoReverseAnimation;

View File

@@ -10,6 +10,14 @@
@implementation LAAnimatableLayer
- (instancetype)initWithDuration:(NSTimeInterval)duration {
self = [super init];
if (self) {
_laAnimationDuration = duration;
}
return self;
}
- (void)play {
[self _resumeLayer:self];
for (CALayer *layer in self.animationSublayers) {
@@ -44,18 +52,18 @@
}
- (void)setAnimationProgress:(CGFloat)animationProgress {
self.speed = 0.0;
self.speed = 0;
self.timeOffset = 0.0;
self.beginTime = 0.0;
self.beginTime = [self convertTime:CACurrentMediaTime() fromLayer:nil];
self.timeOffset = [self convertTime:CACurrentMediaTime() fromLayer:nil] + animationProgress;
self.timeOffset = animationProgress * self.laAnimationDuration;
for (CALayer *layer in self.animationSublayers) {
layer.speed = 0.0;
layer.speed = 0;
layer.timeOffset = 0.0;
layer.beginTime = 0.0;
layer.beginTime = [layer convertTime:CACurrentMediaTime() fromLayer:nil];
layer.timeOffset = [layer convertTime:CACurrentMediaTime() fromLayer:nil] + animationProgress;
layer.timeOffset = animationProgress * self.laAnimationDuration;
}
for (LAAnimatableLayer *layer in self.childLayers) {
@@ -76,18 +84,13 @@
}
-(void)_pauseLayer:(CALayer*)layer {
CFTimeInterval pausedTime = [layer convertTime:CACurrentMediaTime() fromLayer:nil];
layer.speed = 0.0;
layer.timeOffset = pausedTime;
}
-(void)_resumeLayer:(CALayer*)layer {
CFTimeInterval pausedTime = [layer timeOffset];
layer.speed = 1.0;
layer.timeOffset = 0.0;
layer.beginTime = 0.0;
CFTimeInterval timeSincePause = [layer convertTime:CACurrentMediaTime() fromLayer:nil] - pausedTime;
layer.beginTime = timeSincePause;
layer.beginTime = [layer convertTime:CACurrentMediaTime() fromLayer:nil];
}

View File

@@ -43,12 +43,6 @@
- (void)setDebugModeOn:(BOOL)debugModeOn {
_debugModeOn = debugModeOn;
for (LALayerView *child in _layerMap.allValues) {
if ([child isKindOfClass:[LALayerView class]]) {
[child setDebugModeOn:debugModeOn];
child.opacity = debugModeOn ? 0.5 : 1;
}
}
}
- (void)play {
@@ -66,10 +60,24 @@
}
- (void)setAnimationProgress:(CGFloat)animationProgress {
_animationProgress = animationProgress;
for (LALayerView *layerView in _layerMap.allValues) {
[layerView setAnimationProgress:animationProgress];
}
}
- (void)setLoopAnimation:(BOOL)loopAnimation {
_loopAnimation = loopAnimation;
for (LALayerView *layerView in _layerMap.allValues) {
[layerView setLoopAnimation:loopAnimation];
}
}
- (void)setAutoReverseAnimation:(BOOL)autoReverseAnimation {
_autoReverseAnimation = autoReverseAnimation;
for (LALayerView *layerView in _layerMap.allValues) {
[layerView setAutoReverseAnimation:autoReverseAnimation];
}
}
@end

View File

@@ -15,12 +15,11 @@
@interface LAGroupLayerView : LAAnimatableLayer
- (instancetype)initWithShapeGroup:(LAShapeGroup *)shapeGroup
transform:(LAShapeTransform *)transform;
transform:(LAShapeTransform *)transform
withDuration:(NSTimeInterval)duration;
@property (nonatomic, readonly) LAShapeGroup *shapeGroup;
@property (nonatomic, readonly) LAShapeTransform *shapeTransform;
@property (nonatomic, assign) BOOL debugModeOn;
- (void)startAnimation;
@end

View File

@@ -18,8 +18,9 @@
}
- (instancetype)initWithShapeGroup:(LAShapeGroup *)shapeGroup
transform:(LAShapeTransform *)transform {
self = [super init];
transform:(LAShapeTransform *)transform
withDuration:(NSTimeInterval)duration {
self = [super initWithDuration:duration];
if (self) {
_shapeGroup = shapeGroup;
_shapeTransform = transform;
@@ -60,7 +61,8 @@
LAShapeLayerView *shapeLayer = [[LAShapeLayerView alloc] initWithShape:shapePath
fill:currentFill
stroke:currentStroke
transform:currentTransform];
transform:currentTransform
withDuration:self.laAnimationDuration];
[shapeLayers addObject:shapeLayer];
[self addSublayer:shapeLayer];
} else if ([item isKindOfClass:[LAShapeRectangle class]]) {
@@ -68,13 +70,15 @@
LARectShapeLayer *shapeLayer = [[LARectShapeLayer alloc] initWithRectShape:shapeRect
fill:currentFill
stroke:currentStroke
transform:currentTransform];
transform:currentTransform
withDuration:self.laAnimationDuration];
[shapeLayers addObject:shapeLayer];
[self addSublayer:shapeLayer];
} else if ([item isKindOfClass:[LAShapeGroup class]]) {
LAShapeGroup *shapeGroup = (LAShapeGroup *)item;
LAGroupLayerView *groupLayer = [[LAGroupLayerView alloc] initWithShapeGroup:shapeGroup
transform:currentTransform];
transform:currentTransform
withDuration:self.laAnimationDuration];
[groupLayers addObject:groupLayer];
[self addSublayer:groupLayer];
}

View File

@@ -52,6 +52,8 @@ typedef enum : NSInteger {
@property (nonatomic, readonly) LAAnimatablePointValue *anchor;
@property (nonatomic, readonly) LAAnimatableScaleValue *scale;
@property (nonatomic, readonly) BOOL hasOutAnimation;
@property (nonatomic, readonly) BOOL hasInAnimation;
@property (nonatomic, readonly) BOOL hasInOutAnimation;
@property (nonatomic, readonly) NSArray *inOutKeyframes;
@property (nonatomic, readonly) NSArray *inOutKeyTimes;

View File

@@ -92,15 +92,15 @@
}
_shapes = shapes;
BOOL hasInAnmation = (_inFrame.integerValue > composition.startFrame.integerValue);
BOOL hasOutAnimation = (_outFrame.integerValue < composition.endFrame.integerValue);
_hasInOutAnimation = hasInAnmation || hasOutAnimation;
_hasInAnimation = (_inFrame.integerValue > composition.startFrame.integerValue);
_hasOutAnimation = (_outFrame.integerValue < composition.endFrame.integerValue);
_hasInOutAnimation = _hasInAnimation || _hasOutAnimation;
if (_hasInOutAnimation) {
NSMutableArray *keys = [NSMutableArray array];
NSMutableArray *keyTimes = [NSMutableArray array];
CGFloat compLength = composition.endFrame.floatValue - composition.startFrame.floatValue;
if (hasInAnmation) {
if (_hasInAnimation) {
[keys addObject:@1];
[keyTimes addObject:@0];
[keys addObject:@0];
@@ -111,7 +111,7 @@
[keyTimes addObject:@0];
}
if (hasOutAnimation) {
if (_hasOutAnimation) {
[keys addObject:@1];
CGFloat outTime = _outFrame.floatValue / compLength;
[keyTimes addObject:@(outTime)];

View File

@@ -13,8 +13,7 @@
@interface LAParentLayer : LAAnimatableLayer
- (instancetype)initWithParentModel:(LALayer *)parent compBounds:(CGRect)bounds;
- (void)startAnimation;
- (instancetype)initWithParentModel:(LALayer *)parent inComposition:(LAComposition *)comp;
@end
@@ -23,10 +22,10 @@
CAAnimationGroup *_animation;
}
- (instancetype)initWithParentModel:(LALayer *)parent compBounds:(CGRect)bounds {
self = [super init];
- (instancetype)initWithParentModel:(LALayer *)parent inComposition:(LAComposition *)comp {
self = [super initWithDuration:comp.timeDuration];
if (self) {
self.bounds = bounds;
self.bounds = comp.compBounds;
_parentModel = parent;
[self _setupLayerFromModel];
}
@@ -59,19 +58,22 @@
CAAnimationGroup *_animation;
CAKeyframeAnimation *_inOutAnimation;
NSArray<LAParentLayer *> *_parentLayers;
LAComposition *_composition;
}
- (instancetype)initWithModel:(LALayer *)model inComposition:(LAComposition *)comp {
self = [super init];
self = [super initWithDuration:comp.timeDuration];
if (self) {
_layerModel = model;
[self _setupViewFromModelInComposition:comp];
_composition = comp;
[self _setupViewFromModel];
}
return self;
}
- (void)_setupViewFromModelInComposition:(LAComposition *)comp {
self.bounds = comp.compBounds;
- (void)_setupViewFromModel {
self.bounds = _composition.compBounds;
self.anchorPoint = CGPointZero;
_childContainerLayer = [CALayer new];
self.animationSublayers = @[_childContainerLayer];
@@ -81,8 +83,8 @@
NSMutableArray *parentLayers = [NSMutableArray array];
if (parentID) {
while (parentID != nil) {
LALayer *parentModel = [comp layerModelForID:parentID];
LAParentLayer *parentLayer = [[LAParentLayer alloc] initWithParentModel:parentModel compBounds:comp.compBounds];
LALayer *parentModel = [_composition layerModelForID:parentID];
LAParentLayer *parentLayer = [[LAParentLayer alloc] initWithParentModel:parentModel inComposition:_composition];
[parentLayer addSublayer:currentChild];
[parentLayers addObject:parentLayer];
currentChild = parentLayer;
@@ -99,7 +101,7 @@
_childContainerLayer.anchorPoint = _layerModel.anchor.initialPoint;
_childContainerLayer.transform = _layerModel.scale.initialScale;
_childContainerLayer.sublayerTransform = CATransform3DMakeRotation(_layerModel.rotation.initialValue.floatValue, 0, 0, 1);
self.hidden = _layerModel.inFrame.integerValue > comp.startFrame.integerValue;
self.hidden = _layerModel.hasInAnimation;
NSArray *groupItems = _layerModel.shapes;
NSArray *reversedItems = [[groupItems reverseObjectEnumerator] allObjects];
@@ -109,7 +111,7 @@
for (id item in reversedItems) {
if ([item isKindOfClass:[LAShapeGroup class]]) {
LAGroupLayerView *groupLayer = [[LAGroupLayerView alloc] initWithShapeGroup:(LAShapeGroup *)item transform:currentTransform];
LAGroupLayerView *groupLayer = [[LAGroupLayerView alloc] initWithShapeGroup:(LAShapeGroup *)item transform:currentTransform withDuration:self.laAnimationDuration];
[_childContainerLayer addSublayer:groupLayer];
[shapeLayers addObject:groupLayer];
} else if ([item isKindOfClass:[LAShapeTransform class]]) {
@@ -135,7 +137,6 @@
@"transform" : _layerModel.scale,
@"sublayerTransform.rotation" : _layerModel.rotation}];
if (_animation) {
[_childContainerLayer addAnimation:_animation forKey:@"lotteAnimation"];
}
@@ -150,14 +151,11 @@
inOutAnimation.removedOnCompletion = NO;
_inOutAnimation = inOutAnimation;
_inOutAnimation.duration = self.laAnimationDuration;
[self addAnimation:_inOutAnimation forKey:@""];
}
}
- (void)_viewtapped {
NSLog(@"%@", self.layerModel);
}
- (void)setDebugModeOn:(BOOL)debugModeOn {
_debugModeOn = debugModeOn;
self.borderColor = debugModeOn ? [UIColor redColor].CGColor : nil;

View File

@@ -0,0 +1,18 @@
//
// LAMaskLayer.h
// LotteAnimator
//
// Created by brandon_withrow on 7/22/16.
// Copyright © 2016 Brandon Withrow. All rights reserved.
//
#import "LAAnimatableLayer.h"
@interface LAMaskLayer : LAAnimatableLayer
- (instancetype)initWithMasks:(NSArray<LAMask *> *)masks inComposition:(LAComposition *)comp;
@property (nonatomic, readonly) NSArray<LAMask *> *masks;
@end

View File

@@ -0,0 +1,29 @@
//
// LAMaskLayer.m
// LotteAnimator
//
// Created by brandon_withrow on 7/22/16.
// Copyright © 2016 Brandon Withrow. All rights reserved.
//
#import "LAMaskLayer.h"
@implementation LAMaskLayer {
LAComposition *_composition;
}
- (instancetype)initWithMasks:(NSArray<LAMask *> *)masks inComposition:(LAComposition *)comp {
self = [super initWithDuration:comp.timeDuration];
if (self) {
_masks = masks;
_composition = comp;
[self _setupViewFromModel];
}
return self;
}
- (void)_setupViewFromModel {
}
@end

View File

@@ -14,9 +14,7 @@
- (instancetype)initWithRectShape:(LAShapeRectangle *)rectShape
fill:(LAShapeFill *)fill
stroke:(LAShapeStroke *)stroke
transform:(LAShapeTransform *)transform;
- (void)startAnimation;
transform:(LAShapeTransform *)transform
withDuration:(NSTimeInterval)duration;
@end

View File

@@ -7,6 +7,7 @@
//
#import "LARectShapeLayer.h"
#import "CAAnimationGroup+LAAnimatableGroup.h"
@implementation LARectShapeLayer {
LAShapeTransform *_transform;
@@ -25,14 +26,16 @@
- (instancetype)initWithRectShape:(LAShapeRectangle *)rectShape
fill:(LAShapeFill *)fill
stroke:(LAShapeStroke *)stroke
transform:(LAShapeTransform *)transform {
self = [super init];
transform:(LAShapeTransform *)transform
withDuration:(NSTimeInterval)duration {
self = [super initWithDuration:duration];
if (self) {
_rectangle = rectShape;
_stroke = stroke;
_fill = fill;
_transform = transform;
self.allowsEdgeAntialiasing = YES;
self.frame = _transform.compBounds;
self.anchorPoint = _transform.anchor.initialPoint;
self.opacity = _transform.opacity.initialValue.floatValue;
@@ -67,11 +70,34 @@
}
- (void)_buildAnimation {
if (_transform) {
_animation = [CAAnimationGroup animationGroupForAnimatablePropertiesWithKeyPaths:@{@"opacity" : _transform.opacity,
@"position" : _transform.position,
@"anchorPoint" : _transform.anchor,
@"transform" : _transform.scale,
@"sublayerTransform.rotation" : _transform.rotation}];
[self addAnimation:_animation forKey:@"LotteAnimation"];
}
}
if (_stroke) {
_strokeAnimation = [CAAnimationGroup animationGroupForAnimatablePropertiesWithKeyPaths:@{@"strokeColor" : _stroke.color,
@"opacity" : _stroke.opacity,
@"lineWidth" : _stroke.width,
@"bounds" : _rectangle.bounds,
@"position" : _rectangle.position,
@"cornerRadius" : _rectangle.cornerRadius}];
[_strokeLayer addAnimation:_strokeAnimation forKey:@""];
- (void)startAnimation {
}
if (_fill) {
_fillAnimation = [CAAnimationGroup animationGroupForAnimatablePropertiesWithKeyPaths:@{@"backgroundColor" : _fill.color,
@"opacity" : _fill.opacity,
@"bounds" : _rectangle.bounds,
@"position" : _rectangle.position,
@"cornerRadius" : _rectangle.cornerRadius}];
[_fillLayer addAnimation:_fillAnimation forKey:@""];
}
}
@end

View File

@@ -14,7 +14,8 @@
- (instancetype)initWithShape:(LAShapePath *)shape
fill:(LAShapeFill *)fill
stroke:(LAShapeStroke *)stroke
transform:(LAShapeTransform *)transform;
transform:(LAShapeTransform *)transform
withDuration:(NSTimeInterval)duration;
- (void)startAnimation;

View File

@@ -26,8 +26,9 @@
- (instancetype)initWithShape:(LAShapePath *)shape
fill:(LAShapeFill *)fill
stroke:(LAShapeStroke *)stroke
transform:(LAShapeTransform *)transform {
self = [super init];
transform:(LAShapeTransform *)transform
withDuration:(NSTimeInterval)duration {
self = [super initWithDuration:duration];
if (self) {
_path = shape;
_stroke = stroke;

View File

@@ -293,7 +293,7 @@
self.currentScene = laScene;
self.currentSceneView = compView;
[self.view sendSubviewToBack:self.currentSceneView];
[compView performSelector:@selector(play) withObject:nil afterDelay:1];
[compView performSelector:@selector(pause) withObject:nil afterDelay:2];
compView.loopAnimation = YES;
[compView play];
}
@end