标签: uialertviewcontroller

所有警报对话框消息和textField都已更改为单行.请检查图像

以前所有的对话框和textField都运行良好.但不是我不知道这些TextFields如何突然变为单行三联.(就像这里的一些消息......)

    let alert = UIAlertController(title: "Cancel Booking !!", message: "Are you sure you want to cancel your booking?", preferredStyle: .alert)
    alert.addAction(UIAlertAction(title: "No", style: .default, handler: nil))
    alert.addAction(UIAlertAction(title: "Yes", style: .default, handler: self.cancelMessageDialog))
    self.present(alert, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)

演示1 演示3

uitextfield ios swift3 xcode8.2 uialertviewcontroller

7
推荐指数
2
解决办法
1191
查看次数

更改 UIAlertController 的标题字体大小

我试图更改标题fontSize中的UIAlertController,但我不能管理如何我设置NSMutableAttributedStringtitle-属性。

所以我一直在NSMutableAttributedString使用以下代码创建:

let title = NSMutableAttributedString(string: user.fullName)
let range = NSRange(location: 0, length: title.length)
title.addAttribute(NSAttributedStringKey.font, value: UIFont.TextStyle.largeTitle, range: range)
Run Code Online (Sandbox Code Playgroud)

现在对我来说棘手的部分是如何弄清楚如何将新标题设置为UIAlertController,因为它需要一个String?值。

我环顾四周,发现UILabel在呈现UIAlertController. 但是如何使用我自己的自定义覆盖title-property ?UIAlertControllerUILabel

present(myUIAlertController, animated: true) {
    // Creating the UILabel depending on string length
    // Set the NSMutableAttributedString value to the custom UILabel and override title property.
}
Run Code Online (Sandbox Code Playgroud)

或者也许有更简单的方法来解决这个问题?


我的目标是像下图一样:

带有大标题的 UIAlertViewController

nsmutableattributedstring swift uialertviewcontroller swift4

5
推荐指数
1
解决办法
6471
查看次数