1

I have an alert in my project. The alert is simple like every other alert. I d'like to change the font style and color. How is that possible?

Thanks in advance!

Mike
  • 27
  • 9

2 Answers2

1
let attributedString = NSAttributedString(string: "YourTitle", attributes: [
    NSFontAttributeName : UIFont.systemFontOfSize(18), //your font here
    NSForegroundColorAttributeName : UIColor.black()
])
let alert = UIAlertController(title: "TextTitle", message: "YourMessage",  preferredStyle: .Alert)

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

presentViewController(alert,
animated: true,
completion: nil)
Vignesh Davins
  • 285
  • 1
  • 13
1

you can use SweetAlert

SweetAlert().showAlert("Here's a message!", subTitle: "It's pretty, isn't it?", style: AlertStyle.None)

Full documentation & implementation link:https://github.com/codestergit/SweetAlert-iOS

Enamul Haque
  • 4,789
  • 1
  • 37
  • 50