How can I change the color of UIActionSheet button's color?
5 Answers
iOS 8 (UIAlertController)
It's super simple to do if you're using a UIAlertController. Simply change the tint color on the view of the UIAlertController.
[alertController.view setTintColor:[UIColor red];
iOS 7 (UIActionSheet)
I successfully change the text color by using this simple method.
- (void) changeTextColorForUIActionSheet:(UIActionSheet*)actionSheet {
UIColor *tintColor = [UIColor redColor];
NSArray *actionSheetButtons = actionSheet.subviews;
for (int i = 0; [actionSheetButtons count] > i; i++) {
UIView *view = (UIView*)[actionSheetButtons objectAtIndex:i];
if([view isKindOfClass:[UIButton class]]){
UIButton *btn = (UIButton*)view;
[btn setTitleColor:tintColor forState:UIControlStateNormal];
}
}
}
Make sure to run this AFTER you call
[actionSheet showInView];
If you call it before [showInView], all buttons but the cancel button will be colored. Hope this helps someone!

- 4,515
- 3
- 27
- 28
-
1+1 for "Make sure to run this AFTER you call" for this quote. – arunit21 Jul 01 '14 at 10:50
-
Any idea why only in Portrait mode buttons are showing in red but in Landscape mode only cancel button is being colored. – Fouad Aug 10 '14 at 21:37
I have created child class UICustomActionSheet, which allows customize fonts, colors and images of buttons inside UIActionSheet. It is absolutely safety for appstore, you can find code of this class on next link:
https://github.com/gloomcore/UICustomActionSheet
Enjoy it!

- 940
- 7
- 11
-
Are you sure it's ok for the App Store? Anyway the result is great! – Emanuele Fumagalli Mar 07 '12 at 14:35
-
Yes, I am sure, I have used it on apps for Appstore. This class is using no private methods, so it's clear. – Gloomcore Mar 12 '12 at 13:12
-
cancel button don't work if i used a number of otherbuttons and set its font runtime – 9to5ios Jul 10 '13 at 09:33
-
-
Sorry for long waiting, I have pushed the latest changes to implement compatibility with iOs7 and flat design. So you can use it again. – Gloomcore Feb 12 '14 at 22:03
-
According to the Apple docs, `UIActionSheet` should not be subclassed. – memmons Mar 11 '14 at 20:23
-
This message has appeared in version 7.0. UiActionSheet is not designed to be subclassed. But this change is not critical and it's not declined by the Apple team, because it use no private API and is not covered by any other restrictions. – Gloomcore Mar 17 '14 at 16:20
We can use background images to do it. I think it is the easiest way.
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Actionsheet" delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
[actionSheet addButtonWithTitle:@"Button 1"]; //Blue color
[actionSheet addButtonWithTitle:@"Button 2"];
[actionSheet addButtonWithTitle:@"Cancel"];
[actionSheet addButtonWithTitle:nil];
[actionSheet setCancelButtonIndex:2];
[actionSheet setDestructiveButtonIndex:1];
[actionSheet showInView:self.view];
UIButton *button = [[actionSheet subviews] objectAtIndex:1];
UIImage *img = [button backgroundImageForState:UIControlStateHighlighted];//[UIImage imageNamed:@"alert_button.png"];
[button setBackgroundImage:img forState:UIControlStateNormal];

- 184
- 2
- 7
Unfortunately, without using undocumented API's, there is no official way to change the button's color on a UIActionSheet. You may be able to customize this if you subclass the UIActionSheet control.
See this example: http://blog.corywiles.com/customizing-uiactionsheet-buttons

- 54,662
- 15
- 117
- 144
-
-
3It's not difficult to change the button color and you can do it without using undocumented API's. – Rymnel Nov 05 '13 at 21:33
-
You should not subclass `UIActionSheet`. From the documentation: `UIActionSheet is not designed to be subclassed, nor should you add views to its hierarchy. If you need to present a sheet with more customization than provided by the UIActionSheet API, you can create your own and present it modally with presentViewController:animated:completion:.` – memmons Mar 11 '14 at 20:13
You can easily achieve it by using following code
Apple
UIActionSheetDelegate
protocol documentation
- (void)willPresentActionSheet:(UIActionSheet *)actionSheet
{
for (UIView *_currentView in actionSheet.subviews)
{
if ([_currentView isKindOfClass:[UIButton class]])
{
UIButton *button = (UIButton *)_currentView;
[button setTitleColor:YOUR_COLOR forState:UIControlStateNormal];
}
}
}

- 4,166
- 6
- 30
- 59