Skip to content

Instantly share code, notes, and snippets.

@Gaia-Murata
Last active August 29, 2015 14:01
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 Gaia-Murata/1044ec73dc2c493ee358 to your computer and use it in GitHub Desktop.
Save Gaia-Murata/1044ec73dc2c493ee358 to your computer and use it in GitHub Desktop.
customProperty.m
POPAnimatableProperty *countProperty =
[POPAnimatableProperty propertyWithName:@"countUp"
initializer:^(POPMutableAnimatableProperty *prop){
prop.readBlock = ^(UILabel *label, CGFloat values[]) {
//どの値を利用するか
values[0] = [label.text intValue];
};
prop.writeBlock = ^(UILabel *label, const CGFloat values[]) {
//変更した値をどこに更新するか
label.text = [[NSString alloc] initWithFormat:@"%d", (int)values[0]];
};
}];
POPBasicAnimation *countAnimation = [POPBasicAnimation new];
//自作プロパティをセット
countAnimation.property = countProperty;
countAnimation.timingFunction =
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
countAnimation.duration = 10.0f;
countAnimation.fromValue = @(100);
countAnimation.toValue = @(2000);
[_countLabel pop_addAnimation:countAnimation forKey:@"constantAnimation"];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment