'Is a Right-to-Left progress bar possible on iOS?
I've tried sending [UIProgressView setProgress] negative values, and that doesn't work.
Is there some other way to get a progress bar that fills from the right-hand end?
Solution 1:[1]
You can rotate the UIProgressView:
progressView.transform = CGAffineTransformMakeRotation(DegreesToRadians(180));
where DegreesToRadians is:
#define DegreesToRadians(d) ((d) * M_PI / 180.0)
To change the progress value, use positive numbers.
Solution 2:[2]
A simpler version is to flip it horizontally.
progressView.transform = CGAffineTransformMakeScale(-1.0f, 1.0f);
Solution 3:[3]
In iOS 9+, you can use semanticContentAttribute:
progressView.semanticContentAttribute = .forceRightToLeft
Solution 4:[4]
You can rotate the view by 180°:
progressView.transform = CGAffineTransformMakeRotation(-M_PI);
Solution 5:[5]
Swift answer:
progressView.transform = CGAffineTransform(rotationAngle: .pi)
Solution 6:[6]
In iOS 7 with storyboards, you can set the Progress Tint to the Track Tint and vice versa, then subtract the regular value from one and set that to the current progress. Probably better to do it the other (rotation) way, but I thought I would throw this out there.
Solution 7:[7]
Swift 5 Version
progressView.transform = CGAffineTransform(scaleX: -1.0, y: 1.0)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | user4735705 |
| Solution 3 | Joshua C. Lerner |
| Solution 4 | Nick Weaver |
| Solution 5 | Andrey Gordeev |
| Solution 6 | eritbh |
| Solution 7 | Imran Rasheed |
