Skip to content

Instantly share code, notes, and snippets.

@darknoon
Created August 30, 2016 20:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darknoon/fc135cbc22a79ee5fd6025855f419d04 to your computer and use it in GitHub Desktop.
Save darknoon/fc135cbc22a79ee5fd6025855f419d04 to your computer and use it in GitHub Desktop.
- (void)_setValue:(CGFloat)value forAnimatedKey:(NSString *)animationKey
{
POPSpringAnimation *ps = [self pop_animationForKey:animationKey];
if (!ps) {
ps = [POPSpringAnimation animation];
ps.property = [POPAnimatableProperty propertyWithName:animationKey initializer:^(POPMutableAnimatableProperty *prop) {
prop.readBlock = ^(DEViewerView *view, CGFloat *vs) {
vs[0] = [[view valueForKey:animationKey] floatValue];
};
prop.writeBlock = ^(DEViewerView *view, const CGFloat *vs) {
[view setValue:@(vs[0]) forKey:animationKey];
[view setNeedsLayout];
};
prop.threshold = 0.0001;
}];
ps.dynamicsFriction = fromQCFriction(8);
ps.dynamicsTension = fromQCTension(30);
[self pop_addAnimation:ps forKey:animationKey];
}
ps.toValue = @(value);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment