首页 > 解决方案 > 删除 UIAlertController 上文本字段周围的边框

问题描述

我有一个要求,我需要在警报消息后在 UIAlertController 上添加文本字段。我正在使用下面的代码来实现上述要求。

    *anAlertController.addTextField { (textField) in
        textField.allowsEditingTextAttributes = false
        textField.borderStyle = .none
        textField.layer.borderColor = UIColor.clear.cgColor
        textField.layer.borderWidth = 0.0
        textField.backgroundColor = UIColor.clear
        textField.textAlignment = NSTextAlignment.center
        textField.delegate = self
        textField.heightAnchor.constraint(equalToConstant: 50).isActive = true
        textField.text = "123456"
    }*

上面的代码没有删除文本字段周围的边框,也没有与警报背景颜色匹配。但是,如果我尝试使用上面的代码将文本字段添加到 viewcontroller 视图,则会删除边框填充。我在做什么错。你能请任何人建议如何实现这一目标

标签: iosswiftuialertcontroller

解决方案


推荐阅读