如何为 iOS 9-10 在 UIAlertController 的主体中添加我的自定义 UI 组件?
How to add my custom UI component in the body of UIAlertController for iOS 9-10?
我需要在 UIAlertController
的正文中添加一些额外的 UI
组件来创建如下设计的警报。
我没有从 Apples's Documentation 中找到任何 public API。任何人都可以帮助我如何在该警报正文中添加额外的标签和复选框吗?
在 debug view
中花了一个小时后,我终于能够通过以下代码提取 UIAlertController
的 body
let watingListAlert = UIAlertController(title: "Lista De espera",
message: "Algunos días seleccionados, no poseen disponibilidad en el chárter. Puede inscribirse a la lista de espera y el sistema lo tendrá en cuenta cuando algún espacio se libere\n\n\n",
preferredStyle: .alert)
if let alertContentView = watingListAlert.view.subviews[0].subviews.last?.subviews.first?.subviews.first?.subviews[0] {
// alertContentView is the view where title and message labels are drawn
// Create your own UI Native components and add them on this view
}
我终于能够在 UIAlertController
的正文中添加 extra label
和 check box
。您可以在 GitHub 查看我的完整项目。我已经创建了最终结果的 gif。
我需要在 UIAlertController
的正文中添加一些额外的 UI
组件来创建如下设计的警报。
我没有从 Apples's Documentation 中找到任何 public API。任何人都可以帮助我如何在该警报正文中添加额外的标签和复选框吗?
在 debug view
中花了一个小时后,我终于能够通过以下代码提取 UIAlertController
的 body
let watingListAlert = UIAlertController(title: "Lista De espera",
message: "Algunos días seleccionados, no poseen disponibilidad en el chárter. Puede inscribirse a la lista de espera y el sistema lo tendrá en cuenta cuando algún espacio se libere\n\n\n",
preferredStyle: .alert)
if let alertContentView = watingListAlert.view.subviews[0].subviews.last?.subviews.first?.subviews.first?.subviews[0] {
// alertContentView is the view where title and message labels are drawn
// Create your own UI Native components and add them on this view
}
我终于能够在 UIAlertController
的正文中添加 extra label
和 check box
。您可以在 GitHub 查看我的完整项目。我已经创建了最终结果的 gif。