I'm trying to change the title fontSize
in an UIAlertController
, but I can't manage how to set my NSMutableAttributedString
to the title
-property.
So for I've been creating the NSMutableAttributedString
with the following code:
let title = NSMutableAttributedString(string: user.fullName)
let range = NSRange(location: 0, length: title.length)
title.addAttribute(NSAttributedStringKey.font, value: UIFont.TextStyle.largeTitle, range: range)
Now the tricky part for me is how to figure out how to set the new title to the UIAlertController
, because it's expecting a String?
value.
I looked around and found out that I should probably create a UILabel
within the completion block when presenting the UIAlertController
. But how do I override the title
-property in the UIAlertController
with my own custom UILabel
?
present(myUIAlertController, animated: true) {
// Creating the UILabel depending on string length
// Set the NSMutableAttributedString value to the custom UILabel and override title property.
}
Or maybe there's even an easier way to solve this?
UIView
orUITableView
like action sheet? It can be easily customize according to your requirement. Even custom action sheets are available. – Watkin