当语言为阿拉伯语时,我在 IOS 10 中遇到 UIAlertAction 文本对齐问题。
这个问题只是在 IOS 10 上,我怎么能总是设置 textAlignmetCenter ?
谢谢
当语言为阿拉伯语时,我在 IOS 10 中遇到 UIAlertAction 文本对齐问题。
这个问题只是在 IOS 10 上,我怎么能总是设置 textAlignmetCenter ?
谢谢
我已成功使用以下方法来对齐和设置 UIAlertControllers 文本的样式:
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.alignment = NSTextAlignment.Center
let messageText = NSMutableAttributedString(
string: "The message you want to display",
attributes: [
NSParagraphStyleAttributeName: paragraphStyle,
NSFontAttributeName : UIFont.preferredFontForTextStyle(UIFontTextStyleBody),
NSForegroundColorAttributeName : UIColor.blackColor()
]
)
myAlert.setValue(messageText, forKey: "attributedMessage")
如果您使用"attributedTitle"
, 而不是"attributedMessage"