Created
February 6, 2017 08:29
-
-
Save danielgarbien/1587cbf2272eb72e6195c102f493f67a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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