Created
July 11, 2017 06:24
-
-
Save vienvu89/8af47d792e2bf3bc5bd2ea487817dc95 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (id<CAAction>)actionForLayer:(CALayer *)layer forKey:(NSString *)event { | |
if (layer == self.shapeLayer && [event isEqualToString:@"strokeEnd"]) { | |
//Only perform animation action when in a UIView animation block | |
CAAnimation *opacityAction = (id)[super actionForLayer:layer forKey:@"opacity"]; | |
if (opacityAction && ![opacityAction isKindOfClass:[NSNull class]] && [opacityAction isKindOfClass:[CAAnimation class]]) { | |
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:event]; | |
animation.fromValue = [layer.presentationLayer valueForKey:event]; | |
animation.duration = opacityAction.duration; | |
return animation; | |
} else { | |
return [NSNull null]; | |
} | |
} | |
return [super actionForLayer:layer forKey:event]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment