Last active
December 25, 2015 20:39
-
-
Save jpsim/7036492 to your computer and use it in GitHub Desktop.
UIProgressView Always Animates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UIProgressView *v = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleDefault]; | |
v.frame = CGRectMake(40, 100, 240, 2); | |
[self.view addSubview:v]; | |
{ | |
double delayInSeconds = 1.0; | |
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); | |
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ | |
[v setProgress:0.5f animated:NO]; | |
}); | |
} | |
{ | |
double delayInSeconds = 2.0; | |
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); | |
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ | |
[v setProgress:0.75f animated:NO]; | |
}); | |
} | |
{ | |
double delayInSeconds = 3.0; | |
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); | |
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ | |
[v setProgress:1.0f animated:NO]; | |
}); | |
} |
Not sure why, but I have had similar issues with other controls in iOS 7. As a workaround, I found that disabling animations altogether when updating the value and laying out the views takes care of it:
[UIView performWithoutAnimation:^{
[v setProgress:1.0f animated:NO];
[v layoutIfNeeded];
}];
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why does
UIProgressView
'ssetProgress:Animated:
method always animate the change?