I am trying to set an attributed message on an MDCAlertController
that contains a word with bold text. However, it seems that the Material Components library on iOS ignores it and I'm not sure why.
Here is the code I am using and below I've provided a screenshot of the result.
let message = "This should be bold"
let attributedString = NSMutableAttributedString(string: message, attributes: [
.font: UIFont.systemFont(ofSize: 14)
])
attributedString.addAttribute(
.font,
value: UIFont.boldSystemFont(ofSize: 14),
range: (message as NSString).range(of: "bold")
)
let alert = MDCAlertController(
title: "Example alert",
attributedMessage: attributedString
)
alert.addAction(MDCAlertAction(title: "OK"))
present(alert, animated: true)