Domanda

[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.

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top