-(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];