I'm trying to set if condition on the basis of button background color. I've found a solution on stackoverflow but it's not for me because what I'm doing different is my buttons are in an array and if
condition is in a for
loop. It's like checking all the buttons in the array every time a button is tapped and if any button have background color as black don't show the next interface
.
This method is setting those color which is doing good.
for (int i=0; i<10; i++)
{
[buttonsArray[i] setColor:[UIColor blackColor]];
}
Now the problem is in this method:
-(void)myFunction
{
for (int i=0; i<10; i++)
{
if([buttonsArray[i] backgroundColor:[UIColor blackColor]])
{
//code I want to use if the condition is true
}}}
I've also tried the following conditions in if:
if([buttonsArray[i].backgroundColor isequal:[UIColor blackColor]])
//or
if([[buttons[i] background] isEqual:myBlack])
//or
if([buttonsArray[i] backgroundColor]==[UIColor blackColor])
Please not that I'm using setColor
to set the color not setBackgroundColor
and I want to keep it that way because this is a requirement.