Fat*_*han 6 uialertview ios swift
我创建了一个警报视图,我想将警报视图的文本向左对齐并使用此代码。
但问题是它(alert.subviews).count是0。
这是我的代码:
let alert = UIAlertView(title: "Details:", message: "Composer: abcdfg \nShow:sdfa\nPerformer:asdasdf\nLanguage:farsi\nFirst Line:asdfasdfagadf", delegate: nil, cancelButtonTitle: "OK")
for view in alert.subviews{
if view.isKindOfClass(UILabel){
(view as UILabel).textAlignment = NSTextAlignment.Left
}
}
println((alert.subviews).count)
alert.show()
Run Code Online (Sandbox Code Playgroud)
我想将消息左对齐,但警报的子视图计数为 0
警告文本“条款和条件”左对齐
let alertController = UIAlertController(title: "iosGeek", message: "Terms and Condition", preferredStyle: .alert)
let OKAction = UIAlertAction(title: "OK", style: .cancel) { (action) in
alertController.dismiss(animated: true, completion: nil)
}
alertController.addAction(OKAction)
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.alignment = NSTextAlignment.left
let messageText = NSMutableAttributedString(
string: "Terms and Condition",
attributes: [
NSParagraphStyleAttributeName: paragraphStyle,
NSFontAttributeName: UIFont.systemFont(ofSize: 13.0)
]
)
alertController.setValue(messageText, forKey: "attributedMessage")
self.present(alertController, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7313 次 |
| 最近记录: |