Change UIAlertController's title fontsize
You can make title and message of UIAlertController
attributed by using this code. You can customize as per your need. You can see the result in the image. I am not sure you can put it on Appstore.
func showAlert() {
let alert = UIAlertController(title: "", message: "", preferredStyle: .actionSheet)
let titleAttributes = [NSAttributedStringKey.font: UIFont(name: "HelveticaNeue-Bold", size: 25)!, NSAttributedStringKey.foregroundColor: UIColor.black]
let titleString = NSAttributedString(string: "Name Last name", attributes: titleAttributes)
let messageAttributes = [NSAttributedStringKey.font: UIFont(name: "Helvetica", size: 17)!, NSAttributedStringKey.foregroundColor: UIColor.red]
let messageString = NSAttributedString(string: "Company name", attributes: messageAttributes)
alert.setValue(titleString, forKey: "attributedTitle")
alert.setValue(messageString, forKey: "attributedMessage")
let labelAction = UIAlertAction(title: "Label", style: .default, handler: nil)
let deleteAction = UIAlertAction(title: "Delete", style: .destructive, handler: nil)
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
alert.addAction(labelAction)
alert.addAction(deleteAction)
alert.addAction(cancelAction)
self.navigationController?.present(alert, animated: true, completion: nil)
}
How to change font color on UIAlertController on particular action sheet?
Use .destructive
instead of .default
for the action style.
Related Topics
Swiftui: Deleting Last Row in Foreach
Missing Marketing Icon Xcode Bug
How to Add a Button to Uinavigationbar
Modify Uiimage Renderingmode from a Storyboard/Xib File
Transition Animation Not Working in Swiftui
What Is a Monospace Font in iOS
Apple MACh-O Linker Warning "Directory Not Found for Option..."
Return Value from Completion Handler - Swift
Will iOS Region Monitoring Call Didenterregion on My App If My App Is in a Terminated State
What Is Build Object File Extension in iOS
iOS Autolayout Multi-Line Uilabel
Dial a Phone Number with an Access Code Programmatically in iOS
How to Disable Horizontal Scrolling of Uiscrollview