I have some sort of counter built from multiple UIScrollViews containing images of numbers. Counter is periodically updated with old and new number and animation duration. Update is actually for loop always incrementing counter for +1. When I put this into animation block, animation is performed like I just updated it to toValue, like there is no for loop.
What I want is animation to be performed in linear manner, I want to see every number (in case animation is not too fast which isn't). In some weird scenario, counter just jumps to some random number in [fromValue, toValue] interval without animation, and then animated jumps to toValue.
Any suggestions? Here is some code
- (void) setDigit:(UIScrollView*)digit withValue:(int)value
{
CGFloat height = digit.frame.size.height;
[digit setContentOffset:CGPointMake(0, height * value) animated:NO];
}
- (void) updateValue:(int) value
{
for (int i = 5; i >= 0; i--)
{
int a = value % 10;
value = value / 10;
[self setDigit:[digits objectAtIndex:i] withValue:a];
}
}
- (void) transitFromValue:(int)fromValue toValue:(int)toValue withDuration:(float)duration
{
[UIView animateWithDuration:duration
delay:0.0
options:UIViewAnimationCurveLinear
animations:^ {
for (int tValue = fromValue; tValue <= toValue; tValue++)
{
[self updateValue:tValue];
}
}
completion:^(BOOL finished) {
}];
}