How to change button text color of UIAlertView in iOS7?

后端 未结 3 1434
逝去的感伤
逝去的感伤 2020-12-09 09:47

iOS7 introduced general tint-color. I think UIAlertView is also in the valid range, but actually tintColor doesn\'t look to work with UIAlertView.

3条回答
  •  忘掉有多难
    2020-12-09 10:33

    The previous answers mentioning [[UIView appearance] setTintColor:[UIColor redColor]]; should work but this code is doing way more than if should if you want to change only the UIAlertView tint color.

    You can aim the component this way on iOS < 9 :

    [[UIView appearanceWhenContainedIn:[UIAlertView class], nil] setTintColor:[UIColor redColor]];
    [[UIView appearanceWhenContainedIn:[UIAlertController class], nil] setTintColor:[UIColor redColor]];
    

    And on iOS >9 :

    [[UIView appearanceWhenContainedInInstancesOfClasses:@[[UIAlertView class]]] setTintColor:[UIColor redColor]];
    [[UIView appearanceWhenContainedInInstancesOfClasses:@[[UIAlertController class]]] setTintColor:[UIColor redColor]];
    

提交回复
热议问题