-(BOOL)firstColor:(UIColor*)firstColor secondColor:(UIColor*)secondColor
{
if (CGColorEqualToColor(firstColor.CGColor, secondColor.CGColor))
{
NSLog(@"颜色相同");
return YES;
}
else
{
NSLog(@"颜色不同");
return NO;
}
}
适用于:
1.控件的颜色与UIColor的判断
[self firstColor:_startButton.backgroundColor secondColor:[UIColor redColor]];
2.控件之间的颜色判断
[self firstColor:_startButton.backgroundColor secondColor:_closeButton.backgroundColor];