Change Button Title Color in Uialertview

How to change UIAlertController button text colour in iOS9?

I've run into something similar in the past and the issue seems to stem from the fact that the alert controller's view isn't ready to accept tintColor changes before it's presented. Alternatively, try setting the tint color AFTER you present your alert controller:

[self presentViewController:strongController animated:YES completion:nil];
strongController.view.tintColor = [UIColor black];

Change title color in UIAlertController

only red Color is possible when you set UIAlertActionStyle.Destructive

Check this link

UIAlertController custom font, size, color

How to change button text color of UIAlertView in iOS7?

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?

How to change UIAlertView text color?

Check to see if setTextColor is depricated.

I thought it was

theTitle.text.color = [UIColor redColor];

or you could use

[theTitle.text setColor:[UIColor redColor]];

Not totally sure on the second one, the first example should do the trick though.

Swift How to change UIAlertController's Title Color

let attributedString = NSAttributedString(string: "Title", attributes: [
NSFontAttributeName : UIFont.systemFontOfSize(15), //your font here
NSForegroundColorAttributeName : UIColor.redColor()
])

let alert = UIAlertController(title: "", message: "", preferredStyle: .alert)

alert.setValue(attributedString, forKey: "attributedTitle")

let cancelAction = UIAlertAction(title: "Cancel", style: .cancel) { (_) in
}

alert.addAction(cancelAction)

present(alert, animated: true, completion: nil)

Added the correct line of code to my answer as it's much more concise than the answer below.



Related Topics



Leave a reply



Submit