iOS & Swift – Making Custom Rounded-Corner Progress Bar With UIView

iPhone custom slider






TOKYO (MacHouse) – About a week ago, I spotted a topic at stackoverflow where somebody wanted to know how to create a custom progress bar with a rectangle with rounded corners. And I thought to myself “Hmm… I wonder if I could do it simply by using a custom UIView class?” So I launched Xcode 8 and started writing code in Swift (Swift 3). And voila! I guess, it’s not that bad. (See Screenshot 1.)


iOS Swift custom progress bar

Screenshot 1
  iOS Swift custom progress bar

Screenshot 2



In order to create a progress bar like the one shown in Screenshot 1, you probably want to subclass UIView so that you can curve corners of a rectangle, which is an instance of a UIView subclass. let sleepTime = UInt32(animationPeriod/100 * 1000000) In my example, I’m making progress artificial with sleep like



let sleepTime = UInt32(animationPeriod/100 * 1000000)



Click here to watch a quick iPhone Simulator QuickTime movie.

Leave a Reply

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail. You can also subscribe without commenting.