Advertisement
Guest User

Untitled

a guest
Sep 1st, 2014
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. - (void) changeTextColorForUIActionSheet:(UIActionSheet*)actionSheet {
  2. UIColor *tintColor = [UIColor redColor];
  3.  
  4. NSArray *actionSheetButtons = actionSheet.subviews;
  5. for (int i = 0; [actionSheetButtons count] > i; i++) {
  6. UIView *view = (UIView*)[actionSheetButtons objectAtIndex:i];
  7. if([view isKindOfClass:[UIButton class]]){
  8. UIButton *btn = (UIButton*)view;
  9. [btn setTitleColor:tintColor forState:UIControlStateNormal];
  10.  
  11. }
  12. }
  13. }
  14.  
  15. [actionSheet showInView];
  16.  
  17. UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Actionsheet" delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
  18. [actionSheet addButtonWithTitle:@"Button 1"]; //Blue color
  19. [actionSheet addButtonWithTitle:@"Button 2"];
  20. [actionSheet addButtonWithTitle:@"Cancel"];
  21. [actionSheet addButtonWithTitle:nil];
  22. [actionSheet setCancelButtonIndex:2];
  23. [actionSheet setDestructiveButtonIndex:1];
  24. [actionSheet showInView:self.view];
  25. UIButton *button = [[actionSheet subviews] objectAtIndex:1];
  26. UIImage *img = [button backgroundImageForState:UIControlStateHighlighted];//[UIImage imageNamed:@"alert_button.png"];
  27. [button setBackgroundImage:img forState:UIControlStateNormal];
  28.  
  29. - (void)willPresentActionSheet:(UIActionSheet *)actionSheet
  30. {
  31. for (UIView *_currentView in actionSheet.subviews)
  32. {
  33. if ([_currentView isKindOfClass:[UIButton class]])
  34. {
  35. UIButton *button = (UIButton *)_currentView;
  36. [button setTitleColor:YOUR_COLOR forState:UIControlStateNormal];
  37. }
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement