0

I'm using the default style of UIAlertControllerand UIAlertAction but I'm getting white text on white background as in the screenshot

Here is my code:

UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"0237826726" style:UIAlertActionStyleDefault
                                                              handler:^(UIAlertAction * action) {
                                                                    [self callPlaceNumber:@"0237826726"];
                                                              }];
[alert addAction:defaultAction];

UIAlertAction* cancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault
                                                   handler:^(UIAlertAction * action) {
                                                       [alert dismissViewControllerAnimated:YES completion:nil];
                                                   }];

[alert addAction:cancel];
[self presentViewController:alert animated:YES completion:nil];

I searched for the problem and I found that I can add tintColor for the UIAlertController as follow but it didn't work.

alert.view.tintColor = [UIColor blackColor];

Is this a normal behaviour or is there anything wrong in my code?

Sawsan
  • 1,096
  • 10
  • 20
  • 1
    Check this http://stackoverflow.com/questions/25795065/ios-8-uiactivityviewcontroller-and-uialertcontroller-button-text-color-uses-wind/26222502#26222502 – AndreasZ Oct 19 '14 at 08:27
  • It works :), thanks. Add your answer and I'll accept it – Sawsan Oct 19 '14 at 08:35

1 Answers1

1

Setting the tint colour for the UIAlertController can be done through the appearance API:

[[UIView appearanceWhenContainedIn:[UIAlertController class], nil] setTintColor:[UIColor blackColor]];
AndreasZ
  • 1,060
  • 13
  • 16
  • @AndreaZ Hi.. I am successfully able to change the tint of accessory view added in the UIAlertAction but still not able to change the text of UIAlertAction Button title from the white to the desired one. Is there something else to add? – Pratik Shah Jan 21 '16 at 13:32