2014-10-19 4 views
0

Я использую стиль по умолчанию UIAlertController и UIAlertAction, но я получаю белый текст на белом фоне, как на скриншотеIOS 8: UIAlertController Default Style Color

Вот мой код:

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

Я искал проблему, и я обнаружил, что могу добавить tintColor для UIAlertController следующим образом, но это не сработало.

alert.view.tintColor = [UIColor blackColor]; 

Это нормальное поведение или что-то не так в моем коде?

+1

Проверить это http://stackoverflow.com/questions/25795065/ios-8-uiactivityviewcontroller-and-uialertcontroller-button -text-color-uses-wind/26222502 # 26222502 – AndreasZ

+0

Это работает :), спасибо. Добавьте свой ответ, и я соглашусь с ним. – Sawsan

ответ

1

Настройка цвета оттенка для UIAlertController может быть сделано через внешний вид API:

[[UIView appearanceWhenContainedIn:[UIAlertController class], nil] setTintColor:[UIColor blackColor]]; 
+0

@AndreaZ Привет. Я успешно могу изменить оттенок дополнительного вида, добавленный в UIAlertAction, но все же не смог изменить текст названия кнопки UIAlertAction от белого до желаемого. Есть ли что-то еще для добавления? –

Смежные вопросы