Is it possible to animate the change of a UIProgressView
such that the display will move smoothly to the new value?
Kinda like NSProgressIndicator does.
To create your progress bar, you need to add a UIProgressView . Still in the storyboard, drag a new Progress View from the Library inside the Loading View.
Instead of using . transform to increase the height, you need to use a height constraint on the progress bar. This will increase the height and . cornerRadius will act as expected.
withAnimation() takes a parameter specifying the kind of animation you want, so you could create a three-second linear animation like this: withAnimation(.linear(duration: 3)) Explicit animations are often helpful because they cause every affected view to animate, not just those that have implicit animations attached.
If you interested in this please fill a bug report, Duplicate/5883058:
Title: UIProgressView setProgress:(float)value animated:(BOOL)animated
Problem Description:
UIProgressView should
have a setProgress:(float)value animated:(BOOL)animated
function like UISlider
to be able to animate the progress.
https://bugreport.apple.com
The UIProgressView method setProgress:animated:
was added in iOS 5:
[progressView setProgress:1.0 animated:YES];
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIProgressView_Class/index.html
- (void)setProgress:(float)progress animated:(BOOL)animated
animated - YES if the change should be animated, NO if the change should happen immediately.
Available in iOS 5.0 and later.
(Swift version)
The UIProgressView method setProgress:animated:
:
self.progressView.setProgress(1, animated: true)
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIProgressView_Class/index.html
open func setProgress(_ progress: Float, animated: Bool)
animated - TRUE if the change should be animated, FALSE if the change should happen immediately.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With