Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
UIColor ==, !=
func == (left:UIColor, right:UIColor) -> Bool{
let lref:CGColorRef = left.CGColor
let rref:CGColorRef = right.CGColor
let lComponents = CGColorGetComponents(lref)
let rComponents = CGColorGetComponents(rref)
if CGColorGetNumberOfComponents(lref) == CGColorGetNumberOfComponents(rref) {
return floor(lComponents[0]*255) == floor(rComponents[0]*255) &&
floor(lComponents[1]*255) == floor(rComponents[1]*255) &&
floor(lComponents[2]*255) == floor(rComponents[2]*255) &&
floor(lComponents[3]*255) == floor(rComponents[3]*255)
}
else {
return false
}
}
func != (left:UIColor, right:UIColor) -> Bool {
return !(left == right)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.