위쪽으로 계산되는 텍스트에서 숫자의 집계에 애니메이션을 적용하고 싶습니다. 텍스트는 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
감사합니다 ...하지만 그건 내 문제가 해결되지 않습니다. –
그래서'a' 값에서'b' 값으로 갈 때까지 매 x 밀리 초마다 숫자를 변경하는 방법에 대한 질문이 있습니까? 그 대답은 아래의 @rdelmar가 제안한 것처럼'NSTimer'를 사용하는 것입니다. 아니면 귀하의 질문은 두 숫자 사이의 변경 사항의 실제 애니메이션과 관련이 있습니까? – Mathew