POPAnimatableProperty *prop = [POPAnimatableProperty propertyWithName:@"countdown" initializer:^(POPMutableAnimatableProperty *prop) { prop.writeBlock = ^(id obj,const CGFloat values[])
{ NSLog(@"%d",(int)values[]);
NSString *timestring = [NSString stringWithFormat:@"%02d:%02d:%02d",(int)values[]/,(int)values[]%,(int)(values[]*)%];
_lblTest.attributedText = [self formatterTime:timestring];
};
}];
POPBasicAnimation *anBasic = [POPBasicAnimation linearAnimation]; //秒表当然必须是线性的时间函数
anBasic.property = prop; //自定义属性
anBasic.fromValue = @(*); //从0开始
anBasic.toValue = @(); //180秒
anBasic.duration = *; //持续3分钟
anBasic.beginTime = CACurrentMediaTime(); //延迟1秒开始
[_lblTest pop_addAnimation:anBasic forKey:@"countdown"];}
- (NSMutableAttributedString *)formatterTime:(NSString *)currentString
{ NSMutableAttributedString *attribute = [[NSMutableAttributedString alloc]initWithString:currentString];
for (NSInteger i = ; i<; i++)
{
[attribute addAttributes:@{
NSBackgroundColorAttributeName:[UIColor redColor],
NSForegroundColorAttributeName:[UIColor whiteColor], }
range:NSMakeRange(*i, )];
}
return attribute;
}
@end