Skip to content

Instantly share code, notes, and snippets.

@nvkiet
Created September 24, 2015 07:53
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nvkiet/29e4d5b5bef0865ee159 to your computer and use it in GitHub Desktop.
Save nvkiet/29e4d5b5bef0865ee159 to your computer and use it in GitHub Desktop.
UIAlertController TextAlignment
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