3madi 3madi - 17 days ago 7
iOS Question

Making squares disappear - iOS

I am planing to make an app for iPhone

I want to include some squares and assign a number to each square.

when a user taps on a square, it should disappear along with some other squares, for example:
If there are squares (1,2,3,4,5,6,7,8,9,10), the user selects 7 for example, so square number
7 should disappear along with all squares (square > 7) so the remaining squares must be
(1,2,3,4,5,6).

What is the best way to do this ?

Answer

You can create an NSArray of all the buttons and simply set the Alpha of the squares you wish to disappear.

Something like that:

-(void)removeSquersAfterSelection:(NSInteger)selectedSqure
{
  for(NSInteger i=0;i<squersArray;i++){
    if(i<=selectedSqure){
        [squersArray objectAtIndex:i].alpha = 0;
    }

  }
}

Good luck