我想动画计算向上计算digets的计数。文本是类似于You have driven for 0.0km
的UILabel,需要使用计数动画将其更改为You have driven for 143.6km
。有什么办法可以更新动画?更新UILabel文本动画
编辑 下面是我的一些当前的代码,关于其他的动画我已经有了:
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];
}
在这里你去:http://stackoverflow.com/a/6267259/1228534 – graver 2013-02-12 15:01:20
谢谢...但是,这并没有解决我的问题。 – 2013-02-12 15:07:53
那么你的问题是如何改变每个'x'毫秒的数字,直到它从值'a'变为值'b'?答案就是使用'NSTimer',就像下面的@rdelmar建议的那样。或者你的问题与任何两个数字之间的变化的实际动画有关吗? – Mathew 2013-02-12 17:18:16