Created
July 21, 2015 08:13
-
-
Save dorentus/20330490d59594605317 to your computer and use it in GitHub Desktop.
inspired by http://whatcolourisit.scn9a.org
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension NSDate { | |
var color: UIColor { | |
let components = NSCalendar.currentCalendar().components(.CalendarUnitHour | .CalendarUnitMinute | .CalendarUnitSecond, fromDate: self) | |
let rgb = [components.hour, components.minute, components.second].map { | |
CGFloat(strtoul(String($0, radix: 10), nil, 16)) / 255 | |
} | |
return UIColor(red: rgb[0], green: rgb[1], blue: rgb[2], alpha: 1) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment