在UIAlertController中添加标签?

Sno*_*lax 5 ios swift uialertcontroller

我知道您可以添加文本字段,但是可以添加标签UIAlertController吗?

alertController.addTextFieldWithConfigurationHandler({(textField: UITextField!) in
            textField.placeholder = "Hyperlink"
            inputTextField = textField
            inputTextField?.text="www.google.com"
        })
Run Code Online (Sandbox Code Playgroud)

^^文本字段

Ade*_*eel -1

这可以更轻松、更灵活地解决您的问题。 https://github.com/wimagguc/ios-custom-alertview

从 iOS7 开始,addSubview 在 UIAlertView 中不可用。此类的视图层次结构是私有的,不得修改。

作为解决方案,此类创建一个 iOS 样式的对话框,您可以使用任何 UIView 或按钮扩展该对话框。动画和外观也被复制,不需要图像或其他资源。