Skip to content

Instantly share code, notes, and snippets.

@dorentus
Created July 21, 2015 08:13
Show Gist options
  • Save dorentus/20330490d59594605317 to your computer and use it in GitHub Desktop.
Save dorentus/20330490d59594605317 to your computer and use it in GitHub Desktop.
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