
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.)
Screenshot 1
|
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.