我正在使用SCLAlertView https://github.com/dogo/SCLAlertView。添加文本字段。知道如何格式化文本字段吗? 想要格式化添加的电话号码文本字段。
提前
答案 0 :(得分:1)
设置文本字段的NSAttributedString属性。您可以将customTextField添加到SCLAlertView中。这样,您应该能够格式化textBox中的文本。我认为您可能不需要像下面那样设置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)