A UILabel
subclass that displays a countdown
JBCountdownLabel
is UILabel
subclass that displays a countdown with a defined amount of seconds. So you can customise the label just like a native UILabel
and add some cool actions:
- Customise the number of seconds on the countdown.
- You can show just the countdown or the countdown inside a sentence, you chose.
- Restart the countdown.
- Cancel the countdown.
- Change the amount of time on the countdown.
I recommend use CocoaPods to install JBCountdownLabel. Simply add the following line to your Podfile
:
pod 'JBCountdownLabel'
But you can also just drop JBCountdownLabel.m
and JBCountdownLabel.h
in your project.
Add the label to your view:
self.countdownLabel = [[JBCountdownLabel alloc] initWithFrame:CGRectMake(0, 50, 320, 46) format:@"Initiating ignition in %@" time:300 delegate:self];
self.countdownLabel.textColor = [UIColor colorWithRed:0.48 green:0.63 blue:0.07 alpha:1];
[self.view addSubview:self.countdownLabel];
You can change the countdown behaviour:
- (void)restartCountdown;
- (void)cancelCountdown;
- (void)setTime:(int)seconds;
There is an optional delegate
callback to get notified when the countdown ended:
- (void)countdownFinnishInCountdown:(JBCountdownLabel *)countdown;
Build and run the JBCoundownLabelSampleProject
project in Xcode to see JBCountdownLabel
in action.
This code has been created originally to provide a countdown on the activation screen of meets Download the app and test it for free! Feedback is welcome!
- If you found a bug, open an issue.
- If you have a feature request, open an issue.
- If you want to contribute, submit a pull request.
Javier Berlana
JBCountdownLabel is available under the MIT license. See the LICENSE file for more info.
-- ###meets, create and discover plans with your friends.###