I am using new UIAlertController for showing alerts. I have this code:
// nil titles break alert interface on iOS 8.0, so we\'ll be using empty strings
UIAle
Here is an extension for Swift 4.1 and Xcode 9.4.1:
extension UIAlertController{
func addColorInTitleAndMessage(color:UIColor,titleFontSize:CGFloat = 18, messageFontSize:CGFloat = 13){
let attributesTitle = [NSAttributedStringKey.foregroundColor: color, NSAttributedStringKey.font: UIFont.boldSystemFont(ofSize: titleFontSize)]
let attributesMessage = [NSAttributedStringKey.foregroundColor: color, NSAttributedStringKey.font: UIFont.systemFont(ofSize: messageFontSize)]
let attributedTitleText = NSAttributedString(string: self.title ?? "", attributes: attributesTitle)
let attributedMessageText = NSAttributedString(string: self.message ?? "", attributes: attributesMessage)
self.setValue(attributedTitleText, forKey: "attributedTitle")
self.setValue(attributedMessageText, forKey: "attributedMessage")
}}