我想为向上计算的文本中的数字计数设置动画。文本位于类似的 UILabelYou have driven for 0.0km
中,需要更改为You have driven for 143.6km
带有计数动画。有什么办法可以更新动画吗?
编辑 这是我当前的一些代码,关于我已经拥有的其他动画:
if (animated)
{
[UIView beginAnimations:@"scaleAnimation" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:animationDuration];
}
[...]
// Amount pointer
float xForRedBar = redBarFrame.size.width + redBarFrame.origin.x;
CGRect pointerFrame = cell.amountBarPointer.frame;
pointerFrame.origin.x = (xForRedBar - (pointerFrame.size.width/2));
if (pointerFrame.origin.x < 12)
pointerFrame.origin.x = 12;
if (pointerFrame.origin.x >= (308 - (pointerFrame.size.width/2)))
pointerFrame.origin.x = 308 - pointerFrame.size.width;
[cell.amountBarPointer setFrame:pointerFrame];
// Amount bar
CGRect amountBarFrame = cell.amountBar.frame;
amountBarFrame.origin.x = 9+(((302 - amountBarFrame.size.width)/100)*self.procentCompleted);
[cell.amountBar setFrame:amountBarFrame];
// Amount info text
CGRect amountInfoFrame = cell.amountInfo.frame;
amountInfoFrame.origin.x = amountBarFrame.origin.x + 2;
[cell.amountInfo setFrame:amountInfoFrame];
// Amount text
[cell.amountInfo setText:[NSString stringWithFormat:NSLocalizedString(@"You have driven for %@km", nil), self.userAmount]];
[...]
if (self.procentCompleted == 0)
{
[cell.amountBar setAlpha:0];
[cell.amountBarPointer setAlpha:0];
[cell.amountInfo setAlpha:0];
}
else {
[cell.amountBar setAlpha:1];
[cell.amountBarPointer setAlpha:1];
[cell.amountInfo setAlpha:1];
}
if (animated)
{
[UIView commitAnimations];
}