Last active
August 29, 2015 14:01
-
-
Save Gaia-Murata/1044ec73dc2c493ee358 to your computer and use it in GitHub Desktop.
customProperty.m
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
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