Search code examples
iosobjective-cios7uiactionsheet

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


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?


Solution

  • 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];
            }
        }
    }