Text boxes in a UIAlertViewController with a rounded rectangular style. (Swift)

I have no problem adding text fields to the UIAlertController, but I find these text fields to be disgusting. Does anyone know how to make them look more attractive?

My code for adding a textbox:

let pincodeAlert:UIAlertController = UIAlertController(title: alertTitle, message: "Enter your passcode", preferredStyle: UIAlertControllerStyle.Alert)
pincodeAlert.addTextFieldWithConfigurationHandler({ (pinCodeTextField:UITextField!) -> Void in
            pinCodeTextField.placeholder = "Password"
            pinCodeTextField.secureTextEntry = true
pincodeAlert.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel, handler: nil}))
pincodeAlert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: { (action) -> Void in
            //do some other stuff here...
        }))
presentViewController(pincodeAlert, animated: true, completion: nil) 

      

My current alert view text boxes are very square and it doesn't look good.

What I want:

enter image description here

What do I have:

enter image description here

+3


source to share


2 answers


Install alertViewStyle.



alert.alertViewStyle = UIAlertViewStyle.LoginAndPasswordInput

      

0


source


You need to set the border style to the pin field;

            pinCodeTextField.borderStyle = UITextBorderStyleRoundedRect
            pinCodeTextField.placeholder = "Password"
            pinCodeTextField.secureTextEntry = true

      



I also had a black border issue if you have the same look at this answer;

UITextField to UIAlertController (border, backgroundColor)

0


source







All Articles