Sophie Alpert
Sophie Alpert

Reputation: 143134

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.

Upvotes: 32

Views: 19611

Answers (3)

odemolliens
odemolliens

Reputation: 2641

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

Upvotes: 3

pkamb
pkamb

Reputation: 34983

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.

Upvotes: 6

catlan
catlan

Reputation: 25246

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

Upvotes: 62

Related Questions