Search code examples
iosobjective-ccocoa-touchuialertviewuiactionsheet

Change tint color of UIAlertview and UIActionsheet buttons


I am trying to adapt my application for iOS 7. The issue I am having is I can not change the tint color of some controls.

I did add

self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
if (IOS7_OR_LATER)
    self.window.tintColor = [self greenTintColor];

to my app delegate's

           - (BOOL)application:(UIApplication *)application
 didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

It mostly helped but color of message box and action sheet buttons is still the default blue.

How can I recolor all such buttons too?

Some screenshots:

iOS7 message box iOS7 action sheet


Solution

  • As UIAlertView is deprecated You can. Use UIAlertController.

    You can use tintColor property.

    OLD

    The UIAlertView class is intended to be used as-is and does not support subclassing. The view hierarchy for this class is private and must not be modified.

    -From Apple Doc

    You can use tintColor property or You can use Some Custom Library for that, you can find it at cocoacontrols.com.