我创建了带有两个文本字段的警报 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) {
// ...
}
最佳答案
我可以建议你一个更好的方法。 创建自定义 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/