gpt4 book ai didi

ios - SCLAlertView - 如何格式化 addTextField - 电话号码

转载 作者:行者123 更新时间:2023-11-28 23:51:10 26 4
gpt4 key购买 nike

我正在使用 SCLAlertView https://github.com/dogo/SCLAlertView .添加文本字段。知道如何格式化文本字段吗?想要格式化为电话号码添加的文本字段。

提前谢谢

最佳答案

设置文本字段的 NSAttributedString 属性。您可以将 customTextField 添加到 SCLAlertView 中。这样,您应该能够设置文本框中文本的格式。我认为您可能不需要像我下​​面所做的那样设置 customTextField 的所有属性来实现您的目标。

    let alert = SCLAlertView(newWindow: ())
let customTextField = UITextField()
customTextField.attributedText = NSAttributedString(string: "Hello", attributes: [NSAttributedStringKey.foregroundColor : UIColor.red ])
customTextField.contentMode = .left
customTextField.textAlignment = .left
customTextField.frame.size = CGSize(width: 0.0, height: 40.0)
customTextField.borderStyle = .roundedRect
alert?.addCustomTextField(customTextField)
alert?.addTextField("Hello")

alert?.addButton("Show Name") {
print("text value: ")
print(customTextField.text)
}

alert?.showEdit("Edit View", subTitle: "This alert view shows a text box", closeButtonTitle: "Done", duration: 0.0)

enter image description here

关于ios - SCLAlertView - 如何格式化 addTextField - 电话号码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52017427/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com