Swift 4. Getting hex code (UInt) from UIColor:
extension UIColor {
var coreImageColor: CIColor {
return CIColor(color: self)
}
var hex: UInt {
let red = UInt(coreImageColor.red * 255 + 0.5)
let green = UInt(coreImageColor.green * 255 + 0.5)
let blue = UInt(coreImageColor.blue * 255 + 0.5)
return (red << 16) | (green << 8) | blue
}
}