【发布时间】:2013-08-21 19:47:29
【问题描述】:
我有一个UILabel,它将包含一个需要动画以从零增加到给定值的数字。标签放置在UITableView 内,是UITableViewCell 的子视图。由于某些奇怪的原因,我的数字在视图滚动时不会动画。如果我暂停滚动数字动画。为什么会这样以及如何解决?
方法 1 失败:
NSInteger fromValue = 0;
NSInteger toValue = 57; //In this example toValue has to be greater than fromValue
NSString *suffix = @"K";
NSTimeInterval interval = 0.016; //Adjust for different animation speed
NSTimeInterval delay = 0.0;
for (float i = fromValue; i <= toValue; i++)
{
NSString *labelText = [NSString stringWithFormat:@"%0.3f%@", i, suffix];
[numberLabel1 performSelector:@selector(setText:) withObject:labelText afterDelay:delay];
delay += interval;
}
第二个是使用UICountingLabel from Giuthub,它提供了相同的功能但也不起作用。为什么?怎么修?我的使用代码如下:
UICountingLabel *numberLabel1 = [[UICountingLabel alloc] initWithFrame:CGRectMake(0, 105, winSize.width / 2, 40)]; //winSize is
numberLabel1.textAlignment = NSTextAlignmentCenter;
numberLabel1.method = UILabelCountingMethodLinear;
numberLabel1.format = @"%.3f";
[numberLabel1 countFrom:0 to:num1.floatValue withDuration:countDuration];
关于如何使这个“滴答”的任何其他方式?我需要这个动画能够非常糟糕地滚动。
干杯,简。
【问题讨论】:
标签: ios objective-c uitableview animation uiview