Uialertcontroller Change Font Color

Change the color of the message UIAlertController in Swift

You can use attributedStrings to create the color, font, size, and style that you want, and then set the string as the title.

EDIT: Updated with example

let attributedString = NSAttributedString(string: "Invalid Name", attributes: [
NSParagraphStyleAttributeName: paragraphStyle,
NSFontAttributeName : UIFont.systemFontOfSize(15),
NSForegroundColorAttributeName : UIColor.redColor()
])
let alert = UIAlertController(title: "Title", message: "", preferredStyle: .Alert)

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

let cancelAction = UIAlertAction(title: "Cancel",
style: .Default) { (action: UIAlertAction!) -> Void in
}

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

How to change tint color of UIAlertController?

You could just change the tintColor of the underlying view, however, due to a known bug introduced in iOS 9 (https://openradar.appspot.com/22209332), the tintColor is overridden by the application window's tintColor.

You can either:

  1. Change the app tintColor in the AppDelegate.

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {
    self.window.tintColor = UIColor.redColor()
    return true
    }
  2. Reapply the color in the completion block.

    self.presentViewController(alert, animated: true, completion: {() -> Void in
    alert.view.tintColor = UIColor.redColor()
    })

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 font color on UIAlertController on particular action sheet?

Use .destructive instead of .default for the action style.

Change UIAlertController text color

Yes you can do that using this

alert.view.tintColor = UIColor.redColor() // your custom color

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];


Related Topics



Leave a reply



Submit