Ich versuche, ein Textfeld innerhalb eines UIAlertController in Swift in iOS 9.3 zu implementieren, irgendwie bekomme ich Polsterung und einen oberen Rand um das Textfeld.Entfernen Polsterung und Rahmen um TextField in UIAlertController
Bitte beachten Sie den folgenden Screenshot, ich habe einen dicken Rahmen um das Textfeld hinzugefügt, um die Polsterung und oberen Rand/Linie zu markieren.
Der Code für meine UIAlertController:
func handleLoginForgotPassword() {
// create alert controller
let alertController = UIAlertController(title: "Password Reset", message: "\nEnter your email below and press Reset to reset your password.\n", preferredStyle: .Alert)
// create text field for email
alertController.addTextFieldWithConfigurationHandler { textField -> Void in
let tf = textField
tf.placeholder = "Email Address"
tf.autocorrectionType = .No
tf.autocapitalizationType = .None
tf.backgroundColor = UIColor.whiteColor()
tf.layer.borderWidth = 4.0
tf.heightAnchor.constraintEqualToConstant(50).active = true
// pull email from emailTextField if it exists
tf.text = self.emailTextField.text
}
// create "OK" alert action
let actionReset = UIAlertAction(title: "Reset", style: UIAlertActionStyle.Default) {
UIAlertAction in
NSLog("YES Pressed")
// do something
return
}
// create "Cancel" alert action
let actionCancel = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel) {
UIAlertAction in
NSLog("NO Pressed")
// do something
return
}
// add the actions
alertController.addAction(actionReset)
alertController.addAction(actionCancel)
// present the controller
self.presentViewController(alertController, animated: true, completion: nil)
}
Dieses Verhalten scheint seltsam, und ich kann es nicht referenziert finden, wenn für ein ähnliches Problem zu suchen.
Sie haben den borderWith auf 4.0 gesetzt und das ist der Grund, warum Sie eine Grenze sehen. Entferne diese Linie und der Rand wird verschwinden. –
@ChristianAbella Dieser Rand ist nur da, um das Padding/Randproblem um ihn herum darzustellen. Hier ist es ohne die Grenze: http://i.imgur.com/5gckZVu.png](http://i.imgur.com/5gckZVu.png) – iamlolz
welche Polsterung möchten Sie entfernt werden? oben links? –