外側にアニメーションの追加レイヤーが必要です。そうでない場合、進行はすぐに完了します。
+ (void)progressView:(UIProgressView *)progressView progressFinishInTime:(NSTimeInterval)interval {
[UIView animateWithDuration:0
animations:^{
[progressView layoutIfNeeded];
}
completion:^(BOOL finished) {
progressView.progress = 1.0;
[UIView animateWithDuration:interval
delay:0
options:UIViewAnimationOptionCurveLinear
animations:^{
[progressView layoutIfNeeded];
}
completion:^(BOOL finished) {
//动画完成
}];
}];
}
viewDidload など、ビューがレンダリングされていないときに呼び出された場合でも、異常が発生する可能性があります。
UIProgressView *progressView = [UIProgressView new];
//中间省略属性配置。。。。。。
dispatch_async(dispatch_get_main_queue(), ^{
[[self class] progressView:progressView progressFinishInTime:3];
});