Search code examples
iostintcolor

iOS comparing tintcolor doesn't work


Here is a quick example I need some help with. I set the text color to green, then I do a check and see if it is green then do some action. It doesn't work, any ideas on what I'm doing wrong?

[Button1 setTitleColor:[UIColor greenColor] forState:UIControlStateNormal];

if ([Button1.tintColor isEqual: [UIColor greenColor]])
{
ResultTextLabel.text = @"I detected Button1 tint color is GREEN!";
}

It seems so simple yet I've been pulling my hair out for over 3 hrs trying to figure out why this isn't working :(

All help greatly appreciated, thanks!


Solution

  • try this ..

    if ([Button1.titlelabel.textcolor isEqual: [UIColor greenColor]])
    {
        ResultTextLabel.text = @"I detected Button1 tint color is GREEN!";
    }
    

    It's work fine ..