swift - 在 Swift Alert 中的两个 View 之间放置间隙

标签 swift uialertview

我创建了带有两个文本字段的警报 View ,供用户输入详细信息。警报 View 以编程方式生成,如下所示。有什么方法可以在两个文本字段之间添加间隙吗?

 let alertController = UIAlertController(title: "Register", message: "", preferredStyle: .Alert)

alertController.addAction(OKAction)

alertController.addTextFieldWithConfigurationHandler { (textField) in
    textField.placeholder = "Name"
    textField.keyboardType = .EmailAddress
}

alertController.addTextFieldWithConfigurationHandler { (textField) in
    textField.placeholder = "Email"
    textField.secureTextEntry = false
}

alertController.addTextFieldWithConfigurationHandler { (textField) in
    textField.placeholder = "Company"
    textField.secureTextEntry = false
}


        self.presentViewController(alertController, animated: true) {
            // ...
        }

Here the screenshot

最佳答案

我可以建议你一个更好的方法。 创建自定义 xib 文件并使用当前 View Controller 创建警报框,如下所示。

 let vc = CustomAlertViewController()
    self.presentViewController(vc, animated: true, completion: nil)

您可以引用以下仓库 https://github.com/mattneub/custom-alert-view-iOS7

关于swift - 在 Swift Alert 中的两个 View 之间放置间隙,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35033888/

相关文章:

ios - 使用 UIAlertAction 关闭 View Controller

ios - UIAutomation-检查“警报”中的消息并将其与预期消息进行比较

json - 快速解析 JSON 数据

ios - 如何修复 IBOutlet 配置上的 nil 错误和调用 View Controller 时不显示 UI?

ios - 多尺寸 CollectionView 单元格

ios - 如何在闭包中使用 DispatchSemaphore

objective-c - 如何为 UIAlertView 中的按钮编写事件处理程序?

ios - 更改 UIAlertController 背景色

ios - 通过 whatsapp ios 8 分享图片

ios - 将信息传递给 UIAlertView 委托(delegate)