2

this question is similar to this

But, instead of changing the color in every UIAlertController, I want to change it universal like 'AppDelegate'. So, If I change the color in one place, then all the alert controller action button should change to the new color. My question is:

  1. Is it possible to do it from AppDelegate? If not, how can I do it?
  2. Will Apple approve to change the button color to custom in all iOS Versions?
Community
  • 1
  • 1

3 Answers3

6

Yes, It's possible. Add the following line in AppDelegate and all the UIAlertControllers will set the tint color!

[[UIView appearanceWhenContainedIn:[UIAlertController class], nil] setTintColor:[UIColor blackColor]];
Rupom
  • 429
  • 5
  • 10
1

Yes,you can do it. Do one thing:

  1. make a subclass of UIAlertController Class say MyAlertController
  2. in .m file in viewDidLoad method write

self.view.tintColor = [UIColor requiredColor];

it will change the button color. It will work :)

Luca D'Alberti
  • 4,749
  • 3
  • 25
  • 45
0

Below is .h file

@interface MyAlertController : UIAlertController

@end

Below is .m file

@interface MyAlertController ()

@end

@implementation MyAlertController

- (void)viewDidLoad
{

[super viewDidLoad];
    self.view.tintColor = [UIColor redColor];

}
Abhishek Thapliyal
  • 3,497
  • 6
  • 30
  • 69