Skip to content

Commit 08cde4b

Browse files
committed
Added converting codes.
1 parent 8a677fe commit 08cde4b

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

AXAnimationChain/Classes/CoreAnimation/CAAnimation+Convertable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ NS_ASSUME_NONNULL_BEGIN
4040
+ (nullable instancetype)animationWithBasic:(nullable CABasicAnimation *)basicAnimation;
4141
/// Convert animation from CABasicAnimation using custom values function.
4242
///
43-
+ (nullable instancetype)animationWithBasic:(nullable CABasicAnimation *)basicAnimation usingValuesFunction:(nullable double (^)(double t, double b, double c, double d))valuesFunction;
43+
+ (nullable instancetype)animationWithBasic:(nullable CABasicAnimation *)basicAnimation usingValuesFunction:(CAKeyframeValuesFunction _Nullable)valuesFunction;
4444
/// Convert animation from SpringAnimation.
4545
///
4646
/// @param animation spring animation to convert.

AXAnimationChain/Classes/CoreAnimation/CAAnimation+Convertable.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ id CalculateToValueWithByValue(id value, id byValue, BOOL plus) {
308308
}
309309

310310
@implementation CAKeyframeAnimation (Convertable)
311-
+ (instancetype)animationWithBasic:(CABasicAnimation *)basicAnimation usingValuesFunction:(double (^)(double, double, double, double))valuesFunction {
311+
+ (instancetype)animationWithBasic:(CABasicAnimation *)basicAnimation usingValuesFunction:(CAKeyframeValuesFunction)valuesFunction {
312312
if (!basicAnimation) return nil;
313313
CAKeyframeAnimation *keyframe = [CAKeyframeAnimation animation];
314314
keyframe.beginTime = basicAnimation.beginTime;
@@ -476,6 +476,11 @@ + (instancetype)animationWithBasic:(CABasicAnimation *)animation {
476476
@end
477477

478478
@implementation AXDecayAnimation (Convertable)
479+
+ (instancetype)animationWithBasic:(CABasicAnimation *)basicAnimation usingValuesFunction:(CAKeyframeValuesFunction)valuesFunction {
480+
if (!basicAnimation || ![basicAnimation isKindOfClass:CAKeyframeAnimation.class]) return nil;
481+
return [super animationWithBasic:basicAnimation usingValuesFunction:valuesFunction];
482+
}
483+
479484
+ (instancetype)animationWithSpring:(AXCASpringAnimation *)animation {
480485
return [self animationWithBasic:animation];
481486
}

0 commit comments

Comments
 (0)