I modified the code for Swift5 users
What you can achieve through the below code?
you can set the background color of the message (it has 2 options.)
Option2 you need to extend uialertcontroller in your class.
( for me, option 2 works very well (i am setting it as black color).
option 1 looks like a white color layer is on top of the background color.)
change string of button (cancel & confirm ) and color.

let alert = customDialog(title: "title test ", message: "message test")
self.present(alert, animated: true)
func customDialog(title:String, message : String) -> UIAlertController {
let alertController = UIAlertController(title: title, message: message, preferredStyle: UIAlertController.Style.alert)
//Background color option1.
let backView = alertController.view.subviews.last?.subviews.last
backView?.layer.cornerRadius = 10.0
backView?.backgroundColor = UIColor.yellow
//Background option2. (u need to extend uialertcontroller )
/*
alertController.setBackgroundColor(color: UIColor.yellow)
*/
// Change Title With Color and Font:
var myMutableString = NSMutableAttributedString()
myMutableString = NSMutableAttributedString(string: title as String, attributes: [NSAttributedString.Key.font:UIFont(name: "Georgia", size: 18.0)!])
myMutableString.addAttribute(NSAttributedString.Key.foregroundColor, value: UIColor.red, range: NSRange(location:0,length:title.count))
alertController.setValue(myMutableString, forKey: "attributedTitle")
// Change Message With Color and Font
var messageMutableString = NSMutableAttributedString()
messageMutableString = NSMutableAttributedString(string: message as String, attributes: [NSAttributedString.Key.font:UIFont(name: "Georgia", size: 18.0)!])
messageMutableString.addAttribute(NSAttributedString.Key.foregroundColor, value: UIColor.green, range: NSRange(location:0,length:message.count))
alertController.setValue(messageMutableString, forKey: "attributedMessage")
// Action.
let okAction = UIAlertAction(title: "Confirm", style: .default, handler: nil)
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
okAction.setValue(UIColor.orange, forKey: "titleTextColor") //ok in orange color
alertController.addAction(okAction)
alertController.addAction(cancelAction)
// self.present(alertController, animated: true, completion: nil)
return alertController
}
if u select option2. background . please extent below
https://www.swiftdevcenter.com/change-font-text-color-and-background-color-of-uialertcontroller/
extension UIAlertController {
//Set background color of UIAlertController
func setBackgroundColor(color: UIColor) {
if let bgView = self.view.subviews.first, let groupView = bgView.subviews.first, let contentView = groupView.subviews.first {
contentView.backgroundColor = color
}
}
}