In iOS 7, how do I change the color of the options in my UIActionSheet?

Doug Smith picture Doug Smith · Oct 6, 2013 · Viewed 9k times · Source

I use green as the "action color" throughout my app, and I want the options in my UIActionSheets to be green as well, for consistency. How can I change the colour of the UIActionSheet options to green from blue?

Answer

Stephen Melvin picture Stephen Melvin · Oct 6, 2013

Utilize the willPresentActionSheet delegate method of UIActionSheet to change the action sheet button color.

- (void)willPresentActionSheet:(UIActionSheet *)actionSheet
{
    for (UIView *subview in actionSheet.subviews) {
        if ([subview isKindOfClass:[UIButton class]]) {
            UIButton *button = (UIButton *)subview;
            button.titleLabel.textColor = [UIColor greenColor];
        }
    }
}