I just found ways to set the custom font,color and size of string message inside UIAlertController using NSAttributedString.But how can I set line spacing property of that string in swift?
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let alert = UIAlertController(title: "", message: "", preferredStyle: .alert)
var known_String = ""
var actionDone_String = ""
if (self.reports_array[indexPath.row].is_know == 1 ){
known_String = "We have known the problem"
let attributedString = NSAttributedString(string: known_String, attributes: [
NSFontAttributeName : UIFont.systemFont(ofSize: 18), //your font here
NSForegroundColorAttributeName : UIColor.black
])
alert.setValue(attributedString, forKey: "attributedTitle")
}
if (self.reports_array[indexPath.row].is_solved == 1 ){
actionDone_String = "\n\(self.reports_array[indexPath.row].report_reply)"
let attributedMessage = NSAttributedString(string: actionDone_String, attributes: [
NSFontAttributeName : UIFont.systemFont(ofSize: 17), //your font here
NSForegroundColorAttributeName : UIColor().HexToColor(hexString: "32469A", alpha: 1.0),
NSParagraphStyleAttributeName:NSMutableParagraphStyle(),
])
alert.setValue(attributedMessage, forKey: "attributedMessage")
}
let cancelAction = UIAlertAction(title: "Ok",
style: .default) { (action: UIAlertAction!) -> Void in
}
alert.addAction(cancelAction)
DispatchQueue.main.async(execute: {
self.present(alert,animated: true,completion: nil)
})
}