Guest User

Untitled

a guest
Sep 12th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. Easier way to change all the buttons?
  2. b1.backgroundColor = [UIColor redColor];
  3. b2.backgroundColor = [UIColor redColor];
  4. b3.backgroundColor = [UIColor redColor];
  5. b4.backgroundColor = [UIColor redColor];
  6. b5.backgroundColor = [UIColor redColor];
  7. b6.backgroundColor = [UIColor redColor];
  8. b7.backgroundColor = [UIColor redColor];
  9. b8.backgroundColor = [UIColor redColor];
  10. b9.backgroundColor = [UIColor redColor];
  11. b10.backgroundColor = [UIColor redColor];
  12.  
  13. //Make an array of the buttons:
  14. NSArray* buttons=[[NSArray alloc] initWithObjects:b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,nil];
  15. //Loop through them
  16. for(UIButton* b in buttons)
  17. {
  18. b.backgroundColor = [UIColor redColor];
  19. }
  20.  
  21. NSArray* buttonArray=[[NSArray alloc] initWithObjects:b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,nil];
  22.  
  23. [buttonArray makeObjectsPerformSelector:@selector(setBackgroundColor:) withObject:[UIColor redColor]];
Add Comment
Please, Sign In to add comment