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 UIActionSheet buttons background color and button font
Basically what you are trying to do is something you should not do and should never have been doing. UIActionSheet and UIAlertController provide standard views with a very small number of variants and a completely standard appearance. You should not attempt to mess with that.
However, don't give up hope! Nothing stops you from devising your own view that looks however you want. And on iOS 8 (and iOS 7) this is very easy, because you are allowed to make a presented view controller whose view slides onto the screen and covers it only partially, just like an alert sheet. So go ahead and create your own non-standard column of buttons, rather than trying to modify Apple's standard.
UIAlertAction change color
Refer following post:
Change Text Color of Items in UIActionSheet - iOS 8
Although it's related to changing color of UIActionSheet
items but one user has answered according to change color of UIAlertAction
items.
Change Text Color of Items in UIActionSheet - iOS 8
There's an easy way if you still want to use UIActionSheet
instead of UIAlertController
in order to support older iOS versions.
UIActionSheet
actually uses UIAlertController
in iOS 8, and it has a private property _alertController
.
SEL selector = NSSelectorFromString(@"_alertController");
if ([actionSheet respondsToSelector:selector])
{
UIAlertController *alertController = [actionSheet valueForKey:@"_alertController"];
if ([alertController isKindOfClass:[UIAlertController class]])
{
alertController.view.tintColor = [UIColor blueColor];
}
}
else
{
// use other methods for iOS 7 or older.
}
For Swift Below code should works
let alertAction = UIAlertAction(title: "XXX", style: .default) { (action) in
}
alertAction.setValue(UIColor.red, forKey: "titleTextColor")
Related Topics
How to Parse Firestore Fieldvalue to Date in Swift
How to Open to a Specific View Using Home Quick Actions
Swift: Search Bar Created at Auto Focus
Implementing a Hash Combiner in Swift
How to Await X Seconds with Async Await Swift 5.5
Swift: Can Not Use Array Filter in If Let Statement Condition
Pattern Matching in a Swift for Loop
Cannot Convert Value of Type 'Binding<String>' to Expected Argument Type 'Binding<String>'
Cannot Use Tabview on Swiftui, Watchos
Disable Bounce Scrolling for Wkwebview in MACos
Nscollectionviewitem Never Instantiate
Is Is Possible to Use Vapor 3 Postgres Fluent in a Standalone Script
Create Complicated Nscompoundpredicate in Swift 3
Can You Enforce a Typealias in Swift
How to Use Unsafemutablepointer<Opaquepointer> in Swift
Error with Parse Query Findobjectsinbackgroundwithblock
Cabasicanimation Creates Empty Default Value Copy of Calayer