An Objective-C version copy from LeonardoCardoso
Added 24-hours mechanism based on the origin version.
This is a view like the clock of bedtime that can set sleep time, wake time and sleep duration time.
// Time jumps at each five minutes
int sleepTime = 1320; // Hour: 22:00
int wakeTime = 360; // Hour: 06:00
NKBedtimeClock *bedtimeClock = [[NKBedtimeClock alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.width) sleepTimeInMinutes:sleepTime wakeTimeInMinutes:wakeTime];
bedtimeClock.delegate = self;
[contentView addSubview:bedtimeClock];
Watch the changes using this snippet:
- (void)NKBedtimeClock:(NKBedtimeClock *)bedtimeClock didUpdateSleepTime:(NSString *)sleepTime wakeTime:(NSString *)wakeTime sleepDuration:(NSString *)sleepDuration{
NSLog(@"sleepTime:%@, wakeTime:%@, sleepDuration:%@", sleepTime, wakeTime, sleepDuration);
}
You can change the colors whenever you want. Let's say if you want to give an impression of enabling and disabling the clock. To do so, use this function:
// Change nil for the color of your choice
self.bedtimeClock.trackBackgroundColor = nil
...
also{
trackBackgroundColor = nil,
centerBackgroundColor = nil,
wakeBackgroundColor = nil,
wakeColor = nil,
sleepBackgroundColor = nil,
sleepColor = nil,
trackColor = nil,
numberColor = nil,
thickPointerColor = nil,
thinPointerColor = nil,
centerLabelColor = nil
}
See below the full color reference:
BedtimeClock is released under the MIT license. See LICENSE for details.