How to change button text color of UIAlertView in iOS7?

后端 未结 3 1396
逝去的感伤
逝去的感伤 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条回答
  •  萌比男神i
    2020-12-09 10:27

    Unfortunately you cannot customize the appearance of alert views, it is impossible to change the buttons text color.

    It is mentioned clearly in 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.

    Update:

    The question was about iOS7, but now UIAlertView is deprecated, for UIAlertController you can simply change the view tint color:

        let alert = UIAlertController(title: "Gimme a break",
                                    message: "For God sake its iOS7 question!",
                             preferredStyle: .alert)
        alert.view.tintColor = UIColor.red
    

    It is helpful also to check this question: How to change UIAlertController button text colour in iOS9?

提交回复
热议问题