简体   繁体   English

UIAlertController圆角矩形文本字段

[英]UIAlertController rounded rect textfield

I'm having some problems setting up the textfield for my UIAlertController . 我在设置UIAlertController的文本字段时遇到了一些问题。

I'm using this code to add a rounded textfield to the alertcontroller : 我正在使用此代码向alertcontroller添加一个舍入的textfield alertcontroller

[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
  textField.placeholder = @"placeholder";
  textField.borderStyle = UITextBorderStyleRoundedRect;
}];

However, the result is this: 但结果如下:

在此输入图像描述

How do I remove the outer border and background color ? 如何删除外边框背景颜色 So it looks like what they have in this tutorial: http://useyourloaf.com/blog/2014/09/05/uialertcontroller-changes-in-ios-8.html . 所以它看起来像他们在本教程中所拥有的: http//useyourloaf.com/blog/2014/09/05/uialertcontroller-changes-in-ios-8.html

Thanks! 谢谢!

尝试将UItextView的背景颜色设置为[UIColor clearColor]

try 尝试

for textField in alertController.textFields! {
    if let container = textField.superview, let effectView = container.superview?.subviews.first where effectView is UIVisualEffectView {
       container.backgroundColor = UIColor.clearColor()
       effectView.removeFromSuperview()
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM