iOS 9.3のSwiftでUIAlertController内にテキストフィールドを実装しようとしていますが、どうやらパディングとテキスト枠の上の境界線が表示されています。UIAlertControllerのpaddingとborderFieldを削除します。
下のスクリーンショットを参照してください。パディングと上の境界線を強調表示するために、テキストフィールドの周りに太い枠線を追加しました。
私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)
}
この動作は奇妙に思えると私は同様の問題を検索するとき、それは参照を見つけることができません。
borderWithを4.0に設定しているため、境界線が表示されます。その行を削除すると、境界線が消えます。 –
@ChristianAbellaその境界は、その周りのパディング/ボーダーの問題を説明するためだけにあります。ここには境界線がありません:[http://i.imgur.com/5gckZVu.png](http://i.imgur.com/5gckZVu.png) – iamlolz
どのパッドを削除しますか?左上? –