一丶效果
1.gif
二丶代碼
POPAnimatableProperty *prop = [POPAnimatableProperty propertyWithName:@"money" initializer:^(POPMutableAnimatableProperty *prop) {
prop.writeBlock = ^(id obj, const CGFloat values[]) {
UIButton *btn = (UIButton *)obj;
@autoreleasepool {
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setNumberStyle:NSNumberFormatterNoStyle];
[formatter setFormatWidth:9];
[formatter setPositiveFormat:@",##0.00"];
NSString *titleStr = [NSString stringWithFormat:@"%.@",[formatter stringFromNumber:@(values[0])]];
[btn setTitle:titleStr forState:UIControlStateNormal];
}
};
//力學(xué)閥值,值越大writeBlock的調(diào)用次數(shù)越少
prop.threshold = 1;
}];
POPBasicAnimation *anBasic = [POPBasicAnimation easeInEaseOutAnimation];
anBasic.property = prop;
anBasic.fromValue = @(0.00);
anBasic.toValue = @(100000);
anBasic.duration = 3;
[_btn pop_addAnimation:anBasic forKey:@"money"];
三丶解釋:
參考文章: http://geeklu.com/2014/05/facebook-pop-usage/
Pop Animation自帶的動(dòng)畫都是基于POPPropertyAnimation的,POPPropertyAnimation有個(gè)很重要的部分就是 POPAnimatableProperty,用來(lái)描述animatable的屬性。