Reputation: 1727
I'm using the SCLAlertView https://github.com/dogo/SCLAlertView. Adding a text field. Any idea how I can format the text field? Would like to format, the added text field for a phone number.
thx in advance
Upvotes: 0
Views: 248
Reputation: 428
Set the NSAttributedString property of the text field. You can add the customTextField into the SCLAlertView. That way, you should be able to format the text in the textBox. I think you might not need to set all the attributes of customTextField as I am doing below to achieve your goal.
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)
Upvotes: 1