Change text color in UIActionSheet buttons

kiri picture kiri · Apr 23, 2013 · Viewed 42.8k times · Source

In my project, I am using UIActionSheet for displaying for some sorting type. I want to change the color of the text displayed in the action sheet buttons. How can we change the text color?

Answer

jrc picture jrc · Oct 3, 2013

iOS 8: UIActionSheet is deprecated. UIAlertController respects -[UIView tintColor], so this works:

alertController.view.tintColor = [UIColor redColor];

Better yet, set the whole window's tint color in your application delegate:

self.window.tintColor = [UIColor redColor];

iOS 7: In your action sheet delegate, implement -willPresentActionSheet: as follows:

- (void)willPresentActionSheet:(UIActionSheet *)actionSheet
{
    for (UIView *subview in actionSheet.subviews) {
        if ([subview isKindOfClass:[UIButton class]]) {
            UIButton *button = (UIButton *)subview;
            [button setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
        }
    }
}