Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

animate a UIProgressView's change

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.

like image 541
Sophie Alpert Avatar asked Jan 02 '09 23:01

Sophie Alpert


People also ask

How do I use the progress bar in swift5?

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.

How do I increase the height of progress view in Swift?

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.

What is withAnimation Swiftui?

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.


3 Answers

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

like image 190
catlan Avatar answered Oct 08 '22 22:10

catlan


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.

like image 35
pkamb Avatar answered Oct 09 '22 00:10

pkamb


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

like image 43
odemolliens Avatar answered Oct 08 '22 22:10

odemolliens