LoginSignup
2
3

More than 5 years have passed since last update.

UIProgressView を指定した秒数でアニメーションさせる

Posted at

小ネタですが、UIProgressView を指定秒数でアニメーションさせる方法です。

// 初期化
_progressView.progress = 1;
[_progressView layoutIfNeeded];

[UIView animateWithDuration:10 delay:0 options:UIViewAnimationOptionCurveLinear animations:^{
    _progressView.progress = 0;
    [_progressView layoutIfNeeded];
} completion:^(BOOL finished) {
    NSLog(@"アニメーション完了");
}];

[_progressView layoutIfNeeded]; がポイントで、これがないと期待通り動作しません。
カウントダウン表示などに便利です。いつか必ず皆さんのお役に立つでしょう。

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3