diff --git a/POP+MCAnimate/Animations/MCAnimationProxy.h b/POP+MCAnimate/Animations/MCAnimationProxy.h index 14c4642..d5fe4d4 100644 --- a/POP+MCAnimate/Animations/MCAnimationProxy.h +++ b/POP+MCAnimate/Animations/MCAnimationProxy.h @@ -22,7 +22,8 @@ @interface NSObject (MCAnimationProxy) -+ (void)pop_addAnimatablePropertyWithName:(NSString *)propertyName readBlock:(void (^)(id obj, CGFloat values[]))readBlock writeBlock:(void (^)(id obj, const CGFloat values[]))writeBlock threshold:(CGFloat)threshold; ++ (void)pop_addAnimatablePropertyWithName:(NSString *)propertyName readBlock:(void (^)(id obj, CGFloat values[]))readBlock writeBlock:(void (^)(id obj, const CGFloat values[]))writeBlock threshold:(CGFloat)threshold __attribute__((deprecated)); ++ (void)pop_registerAnimatablePropertyWithName:(NSString *)propertyName readBlock:(void (^)(id obj, CGFloat values[]))readBlock writeBlock:(void (^)(id obj, const CGFloat values[]))writeBlock threshold:(CGFloat)threshold; @end @@ -30,14 +31,19 @@ @interface NSObject (MCAnimationProxy_DropPrefix) -+ (void)addAnimatablePropertyWithName:(NSString *)propertyName readBlock:(void (^)(id obj, CGFloat values[]))readBlock writeBlock:(void (^)(id obj, const CGFloat values[]))writeBlock threshold:(CGFloat)threshold; ++ (void)addAnimatablePropertyWithName:(NSString *)propertyName readBlock:(void (^)(id obj, CGFloat values[]))readBlock writeBlock:(void (^)(id obj, const CGFloat values[]))writeBlock threshold:(CGFloat)threshold __attribute__((deprecated)); ++ (void)registerAnimatablePropertyWithName:(NSString *)propertyName readBlock:(void (^)(id obj, CGFloat values[]))readBlock writeBlock:(void (^)(id obj, const CGFloat values[]))writeBlock threshold:(CGFloat)threshold; @end @implementation NSObject (MCAnimationProxy_DropPrefix) + (void)addAnimatablePropertyWithName:(NSString *)propertyName readBlock:(void (^)(id obj, CGFloat values[]))readBlock writeBlock:(void (^)(id obj, const CGFloat values[]))writeBlock threshold:(CGFloat)threshold { - [self pop_addAnimatablePropertyWithName:propertyName readBlock:readBlock writeBlock:writeBlock threshold:threshold]; + [self pop_registerAnimatablePropertyWithName:propertyName readBlock:readBlock writeBlock:writeBlock threshold:threshold]; +} + ++ (void)registerAnimatablePropertyWithName:(NSString *)propertyName readBlock:(void (^)(id obj, CGFloat values[]))readBlock writeBlock:(void (^)(id obj, const CGFloat values[]))writeBlock threshold:(CGFloat)threshold { + [self pop_registerAnimatablePropertyWithName:propertyName readBlock:readBlock writeBlock:writeBlock threshold:threshold]; } @end diff --git a/POP+MCAnimate/Animations/MCAnimationProxy.m b/POP+MCAnimate/Animations/MCAnimationProxy.m index a53c9e5..abf4aa6 100644 --- a/POP+MCAnimate/Animations/MCAnimationProxy.m +++ b/POP+MCAnimate/Animations/MCAnimationProxy.m @@ -161,6 +161,10 @@ - (POPAnimatableProperty *)__animatablePropertyForPropertyName:(NSString *)prope @implementation NSObject (MCAnimationProxy) + (void)pop_addAnimatablePropertyWithName:(NSString *)propertyName readBlock:(void (^)(id, CGFloat *))readBlock writeBlock:(void (^)(id, const CGFloat *))writeBlock threshold:(CGFloat)threshold { + [self pop_registerAnimatablePropertyWithName:propertyName readBlock:readBlock writeBlock:writeBlock threshold:threshold]; +} + ++ (void)pop_registerAnimatablePropertyWithName:(NSString *)propertyName readBlock:(void (^)(id, CGFloat *))readBlock writeBlock:(void (^)(id, const CGFloat *))writeBlock threshold:(CGFloat)threshold { NSString *className = NSStringFromClass(self); NSString *domainName = [NSString stringWithFormat:@"%@.%@", className, propertyName]; POPAnimatableProperty *property = [POPAnimatableProperty propertyWithName:domainName initializer: ^(POPMutableAnimatableProperty *prop) { diff --git a/POP-Demo/POP-Demo/MCViewController.m b/POP-Demo/POP-Demo/MCViewController.m index 4f24d3c..3382668 100644 --- a/POP-Demo/POP-Demo/MCViewController.m +++ b/POP-Demo/POP-Demo/MCViewController.m @@ -179,7 +179,7 @@ - (void)viewDidLoad { #endif // declare custom property - [UILabel addAnimatablePropertyWithName:@"textColor" readBlock:^(UILabel *label, CGFloat values[]) { + [UILabel registerAnimatablePropertyWithName:@"textColor" readBlock:^(UILabel *label, CGFloat values[]) { POPUIColorGetRGBAComponents(label.textColor, values); } writeBlock:^(UILabel *label, const CGFloat values[]) { label.textColor = POPUIColorRGBACreate(values); diff --git a/README.md b/README.md index 0e3d82b..ede5546 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ The `finished` flag in the completion handler will return `NO` if any of the ani You can make any property animatable by first declaring it: - [UILabel addAnimatablePropertyWithName:@"textColor" readBlock:^(UILabel *label, CGFloat values[]) { + [UILabel registerAnimatablePropertyWithName:@"textColor" readBlock:^(UILabel *label, CGFloat values[]) { POPUIColorGetRGBAComponents(label.textColor, values); } writeBlock:^(UILabel *label, const CGFloat values[]) { label.textColor = POPUIColorRGBACreate(values);