Is it possible to have buttons in UIActionSheet
in iOS 7's tintColor
color? I mean if my app is in brand tintColor
, for example red, I don't want blue buttons in action sheet. The same with UIAlertView
.

- 3,319
- 2
- 34
- 45

- 4,519
- 6
- 43
- 56
-
1http://stackoverflow.com/questions/16713307/uialertview-change-background-color – John Riselvato Oct 24 '13 at 20:07
-
John Riselvato is right in linking to the answer, "No, neither UIAlertView or UIActionSheet are designed by Apple to be subclassed." For custom appearance, you need to roll your own. – ryan cumley Oct 24 '13 at 20:29
-
1http://stackoverflow.com/questions/4248400/uiactionsheet-buttons-color/19191489#19191489 – Rymnel Oct 29 '13 at 18:01
-
https://github.com/gloomcore/UICustomActionSheet – Gloomcore Feb 12 '14 at 22:28
3 Answers
I want to stress that this violates Apple's rules, but this works:
- (void)willPresentActionSheet:(UIActionSheet *)actionSheet
{
[actionSheet.subviews enumerateObjectsUsingBlock:^(UIView *subview, NSUInteger idx, BOOL *stop) {
if ([subview isKindOfClass:[UIButton class]]) {
UIButton *button = (UIButton *)subview;
button.titleLabel.textColor = [UIColor greenColor];
NSString *buttonText = button.titleLabel.text;
if ([buttonText isEqualToString:NSLocalizedString(@"Cancel", nil)]) {
[button setTitleColor:[UIColor greenColor] forState:UIControlStateNormal];
}
}
}];
}
(conform to UIActionSheetDelegate
)
Not tried UIAlertView yet.

- 19,175
- 22
- 126
- 148
-
4You should be using the following method to update the button title color: [button setTitleColor:[UIColor greenColor] forState:UIControlStateNormal]; – Brody Robertson Mar 12 '14 at 19:42
It is possible. Here is a quick implementation for iOS7:
@interface LNActionSheet : UIActionSheet
{
NSString* _destructiveButtonTitle;
UIColor* _customtintColor;
}
@end
@implementation LNActionSheet
- (id)initWithTitle:(NSString *)title delegate:(id<UIActionSheetDelegate>)delegate cancelButtonTitle:(NSString *)cancelButtonTitle destructiveButtonTitle:(NSString *)destructiveButtonTitle otherButtonTitles:(NSString *)otherButtonTitles, ...
{
self = [super initWithTitle:title delegate:delegate cancelButtonTitle:cancelButtonTitle destructiveButtonTitle:destructiveButtonTitle otherButtonTitles:nil];
if(self)
{
va_list list;
va_start(list, otherButtonTitles);
for(NSString* title = otherButtonTitles; title != nil; title = va_arg(list, NSString*))
{
[self addButtonWithTitle:title];
}
va_end(list);
_destructiveButtonTitle = destructiveButtonTitle;
}
return self;
}
- (void)setTintColor:(UIColor *)tintColor
{
_customtintColor = tintColor;
}
-(void)tintColorDidChange
{
[super tintColorDidChange];
for(id subview in self.subviews)
{
if([subview isKindOfClass:[UIButton class]])
{
UIButton* button = subview;
if(![button.titleLabel.text isEqualToString:_destructiveButtonTitle])
{
[button setTitleColor:_customtintColor forState:UIControlStateNormal];
}
}
}
}
@end
Before showing, set the tint color of the action sheet to your liking.
In this implementation, I have elected to keep the destructive button title as red, but this can be changed.

- 56,823
- 9
- 150
- 195
Please look at my child class UICustomActionSheet. I've just pushed the latest changes, which allow to display styling correctly for iOs6 and iOs7 design. https://github.com/gloomcore/UICustomActionSheet
You can set the colors, fonts, text colors and also images for each buttons. Works fine both for iPhone and iPad. Component is absolutely safety for Appstore so you can use it in your applications. Enjoy!

- 940
- 7
- 11