A few days ago, I wanted to create a rounded progress bar in swift
I watched many Videos and googled a lot.
In the most of the times the code did not work to it was too complex to understand. After some days I got it.
I thought, there must be some easier way and so created this code here.
It will look like this:
The code will be really easy to use.
It was not simple for me to find out how to make a progress bar rounded.
So I created a reusable code, so everybody can use it simple. I created a class.
Here is the class:
And here is how to use:
Create a new progress view
If you use nil for the line width, a filled circle will appear like the second picture above.
Set the progress- and the track color:
If you use progressView.trackColorToProgressColor() set a track color to the progress color, but with a less alpha.
Set the position of the progressView (example):
You can use this because the progressView is of type UIView.
Add the progressView as a subview of the ViewControllers view:
Set the progress of the progressView:
The progress will be animated. If you don't want to animate the progress you can set the progressView.timeToFill to 0. If you want a faster or lower animating you can use this method, too.
I hope this code was helpful.