-
Notifications
You must be signed in to change notification settings - Fork 288
How get current ring value? #14
Comments
Confused about what you mean by this, could you elaborate a bit more? Why would you want to set the progress of the ring to its current value, that wouldn't animate or cause any changes. To get the current value you just need to do |
I found a solution, but in my opinion not very nice
//...
//...
|
The reason you're getting the wrong value is because you are not using the completion handler... Animations take time, unless you use a duration of 0 which will update it instantly. In order to find value AFTER animation you must get the ring value in the completion handler. Here is an example: override func viewDidLoad() {
super.viewDidLoad()
print("Value before: \(ring.value)") // OUTPUT: "Value before: 0.0"
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
ring.setProgress(value: 9, animationDuration: 5) {
print("Value after: \(self.ring.value)") // OUTPUT: "Value after: 9.0"
}
} There is no need to use time intervals or logic for that. Just set a completion handler, this will get called when the ring is done animating. Please look at the documentation if you have some more questions or let me know if this helps. |
Your example does not include pressing the button. |
I'm not going to write a full example as I don't have the time currently. But this should work as intended. If you're using an IBAction then you would call the set progress in there. If you would like more help, please either post your project on here or send me an email with the project if you prefer to keep it private and I can take a look at it. |
I see what you're saying now. You would like to get the value and have it be an updating value as the progress ring is animating. This, however, is not a feature that was originally expected to be needed, so was never added and is not currently something I have the time to add. When I get a chance to look at it again I may be able to add this. However, you could also fork the repo and send a pull request and I'll gladly accept any changes after review! |
- Add a property for accessing the current value of the progress ring while animating, closes [issue #14](#14) - Add fix for removing a currently running animation when calling `setProgress(:)` while ring is animating, closes [issue #19](#19) - Fixed access levels for variables and functions, changed from `public` to `open` to allow subclassing. - Updated `docs` by running Jazzy
Got around to fixing this in version 1.3.0. You can now access the current value by using Thanks for posting your issue! Read the upated docs here |
Nice work dude! |
@NickAwesome, please read the error message Xcode is giving you. If you want to set the value then call .setProgress(value:duration) |
My view contains a button, after buttonTap I want to speed up the ring starting now like as
ring.setProgress(value: ring.currentValue, animationDuration: 5 , completion: nil)
The text was updated successfully, but these errors were encountered: