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
Itms-90809: Deprecated API Usage - Existing App That Use Uiwebview Are No Longer Accepted
Flutter: Disable Swipe to Navigate Back in iOS and Android
How to Set the Rootviewcontroller with Swift, iOS 7
How to Get 18-Digit Current Timestamp in Swift
Will Push Notification Still Work After Ownership Transfer in Itunesconnect
Dyld: Library Not Loaded for a Framework Within a Framework
Custom Scenekit Geometry in Swift on iOS Not Working But Equivalent Objective C Code Does
Get Device Current Orientation (App Extension)
Checking Push Notification Registration: Isregisteredforremotenotifications Not Updating
Ignore Manual Entries from Apple Health App as Data Source
Xcode 5/iOS 7 - Localization Not Working in Simulator
Using Sysctlbyname() from Swift
Apple MACh-O Linker (Id) Warning:Building for MACosx, But Linking Against Dylib Built for iOS
How to Unwind Through Multiple Views Without Displaying Intermediate Views
Send Image Along with Other Parameters with Afnetworking
Learn About the Nsxmlparser in iOS
How to Access a _Block Variable, After the Block Has Completed
How to Create/Extract an Array of Views Using @Viewbuilder in Swiftui