Created
September 24, 2015 07:53
-
-
Save nvkiet/29e4d5b5bef0865ee159 to your computer and use it in GitHub Desktop.
UIAlertController TextAlignment
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
if #available(iOS 8.0, *) { | |
let alertController = UIAlertController(title: "Terms & Conditions", message: kTermsAndConditions, preferredStyle: .Alert) | |
let OKAction = UIAlertAction(title: "OK", style: .Cancel) { (action) in | |
alertController.dismissViewControllerAnimated(true, completion: nil) | |
} | |
alertController.addAction(OKAction) | |
let paragraphStyle = NSMutableParagraphStyle() | |
paragraphStyle.alignment = NSTextAlignment.Left | |
let messageText = NSMutableAttributedString( | |
string: kTermsAndConditions, | |
attributes: [ | |
NSParagraphStyleAttributeName: paragraphStyle, | |
NSFontAttributeName: UIFont.systemFontOfSize(13.0) | |
] | |
) | |
alertController.setValue(messageText, forKey: "attributedMessage") | |
self.presentViewController(alertController, animated: true, completion: nil) | |
} | |
else { | |
// Fallback on earlier versions | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment