UIColor does not define isEqual, isEqual inherits from NSObject. Thus, isEqual compares color addresses and failure.
CGColor has a comparison function CGColorEqualToColor():
CGColor *c = myColor.CGColor;
Then you can compare the colors of CGColor:
bool colorsEqual = CGColorEqualToColor(myColor1.CGColor, myColor2.CGColor);
Or get the individual components of two colors and compare them separately using
- (BOOL)getRed:(CGFloat *)red green:(CGFloat *)green blue:(CGFloat *)blue alpha:(CGFloat *)alpha
source
share