0
[UIView animateWithDuration:10000 animations:^{
    [self.RecomendedBar setProgress:self.whatProgressbarShouldBe animated:NO];
}];

It's pretty obvious that I set progress within an animation block whose time I set at 10k

Yet it's still so fast. Less than 1 seconds.

In fact, if I do this:

    [self.RecomendedBar setProgress:self.whatProgressbarShouldBe animated:NO];
    [UIView animateWithDuration:10000 animations:^{

    }];

It is still animated with less than 1 seconds even thought the progressview bar is outside animation block.

user4951
  • 32,206
  • 53
  • 172
  • 282
  • The `progress` property is not animatable. – rmaddy Dec 11 '13 at 04:39
  • UIProgressView does a great job of reflecting the changes in variables as they update over time, things like large network operations or long-running calculations. UIProgressView is not a clock, however, and it will not do a good job of tracking variables that aren't actually changing. If you absolutely need to force UIProgressView to measure nothing but time, David's solution is certainly reasonable. – Alex Shepard Dec 11 '13 at 04:58

1 Answers1

2

one way to do this would be to use an NSTimer to generate time intervals used to update the progress bar. for example, to make a 15 second long progress bar:

 NSTimer *progressTimer = [NSTimer scheduledTimerWithTimeInterval:0.25f target:self selector:@selector(updateProgressBar) userInfo:nil repeats:YES];

 - (void)updateProgressBar {
     float newProgress = [self.progressBar progress] + 0.01666; // 1/60
     [self.progressBar setProgress:newProgress animated:YES];
 }

declare the updateProgressBar method in your header. the increment is 0.016666... or 1/60, because a 0.25 second timer interval will occur 60 times in 15 seconds.

David Schwartz
  • 507
  • 3
  • 14