3

I have the following code which works perfectly on iOS 8:

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

    // some app initialization code comes here
    // ...

    // set the global tint color - works great on iOS 8!
    [[UIView appearance] setTintColor:[self myGlobalTintColor]];
}

However, when I run the same code on iOS 9 beta 5 (XCode 7, beta 6) the following appears when UIActionSheet (or UIAlertController) is displayed: enter image description here

As you can see, the "Cancel" button does not accept the global tint color. Is this a known issue with iOS 9, or am I missing some code?

Joshua
  • 1,974
  • 2
  • 23
  • 39
  • 1
    Might have something to do with the fact that `UIActionSheet` is deprecated as of iOS 8.3. From the docs: `UIActionSheet is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleActionSheet instead` – sbarow Aug 26 '15 at 11:09
  • Thanks for tip. I just tried using UIAlertController instead of UIActionSheet but it didn't fix the issue. Any other suggestions? – Joshua Aug 26 '15 at 11:47
  • 1
    Have a look at this http://stackoverflow.com/a/26222502/1186243 note the last comment. – sbarow Aug 26 '15 at 12:04
  • 1
    Do you refer to the last answer suggesting to use [[UIView appearanceWhenContainedIn:[UIAlertController class], nil] setTintColor:[UIColor blackColor]] ? If yes, then I already tried it, and it has no effect on iOS 9 Beta 5. – Joshua Aug 26 '15 at 13:04
  • If you set the tint color of the window `self.window.tintColor = [self myGlobalTintColor];`, the "Cancel" button is also tinted. – albertamg Sep 11 '15 at 13:12
  • 1
    The `UIAlertController` tinting is not working properly in iOS 9 GM, see this [radar](https://openradar.appspot.com/22209332). – albertamg Sep 11 '15 at 13:19
  • albertamg, thanks for your comment. Please note that I am not using UIAlertController in my project... I am using UIAlertView and UIActionSheet which are not being affected by self.window.tintColor. – Joshua Sep 11 '15 at 17:21

2 Answers2

2

In iOS 9.0 it seems only changing the window tint helps nothing else seems to work, including the appearanceWhenContainedIn: trick.

Andy
  • 376
  • 4
  • 19
1

While using UIAlertController for ActionSheet, make sure to set the tint color after presenting the alert Controller.

activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: appActivities)
presentViewController(activityVC!, animated: true, completion: nil)
activityVC?.view.tintColor = UIColor.snapdealBlueColor()
Undo
  • 25,519
  • 37
  • 106
  • 129
Abhishek Kumar
  • 324
  • 2
  • 8