Change button title color in UIAlertView

后端 未结 7 1390
予麋鹿
予麋鹿 2021-01-11 17:29

How can I change the color of the UIAlertView button title.

\"enter

相关标签:
7条回答
  • 2021-01-11 18:03

    Actually, you can change the tint color of the view of the UIAlertController in iOS8.

    UIAlertController *alertController = ....
    [alertController.view setTintColor:[UIColor greenColor]];
    
    0 讨论(0)
  • 2021-01-11 18:04

    You can't change alert views. If you really needed you can use custom ones.

    0 讨论(0)
  • 2021-01-11 18:05

    The best way (And easiest) is the following:

    alert = UIAlertController(title: "foo", message: "foo", preferredStyle: UIAlertControllerStyle.Alert)
    alert.addAction.... foo
    ...foo
    alert.view.backgroundColor = UIColor.orangeColor()
    alert.view.tintColor = UIColor.orangeColor()
    alert.view.layer.cornerRadius = 0.5 * alert.view.bounds.size.width
    

    It gives also a plus effect of a "round faded orange circle" in the background.

    Hope it helps

    0 讨论(0)
  • 2021-01-11 18:09

    for Swift 3, use:

    alertController.view.tintColor = UIColor.red
    

    AFTER you present your alert controller

    0 讨论(0)
  • 2021-01-11 18:15

    try this:

    [[UIView appearance] setTintColor:[UIColor whiteColor]];
    
    0 讨论(0)
  • 2021-01-11 18:16

    Can't customize the appearance of alert views.

    For more info UIAlertView Class Reference:

    The UIAlertView class is intended to be used as-is and does not support subclassing. The view hierarchy for this class is private and must not be modified.

    For more info : How to change button text color of UIAlertView in iOS7?

    0 讨论(0)
提交回复
热议问题