Circular Progress Timer working demo in Objective-C for iOS 6+
This is my take on a control that is getting too mainstream :) Is a snippet of what I used on the Madrid Bus App:
The project uses Interface Builder only for the main View Controller, but the circular progress view is built programatically.
No extra frameworks needed, just UIKit.
- Copy and paste CircularProgressBarView header and implementation files into your project. Don't forget the
circle.png
andcircle@2x.png
files. - Kick-off a timer with a one second interval whose action points to the progress bar drawing method. You can see the full example in MainViewController.m:
timer = [NSTimer scheduledTimerWithTimeInterval:1.0
target:self
selector:@selector(updateCircularProgressBar)
userInfo:nil
repeats:YES];
- In the updateCircularProgressBar method, just call the drawing function passing the total amount of seconds left. Show the remaining amount of time in minutes and seconds is a simple operation:
minutesLeft = globalTimer / 60;
secondsLeft = globalTimer % 60;
[self drawCircularProgressBarWithMinutesLeft:minutesLeft secondsLeft:secondsLeft]