Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielgarbien/1587cbf2272eb72e6195c102f493f67a to your computer and use it in GitHub Desktop.
Save danielgarbien/1587cbf2272eb72e6195c102f493f67a to your computer and use it in GitHub Desktop.
import UIKit
extension UIAlertController {
func setLeftAlignedMessage(_ message: String) {
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.alignment = .left
let messageText = NSMutableAttributedString(
string: message,
attributes: [
NSParagraphStyleAttributeName: paragraphStyle,
NSFontAttributeName : UIFont.preferredFont(forTextStyle: UIFontTextStyle.body),
NSForegroundColorAttributeName : UIColor.black
]
)
setValue(messageText, forKey: "attributedMessage")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment