How can I change the color of UIActionSheet button's color?
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!
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!
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With