UIAlertController rounded rect textfield

968 views Asked by At

I'm having some problems setting up the textfield for my UIAlertController.

I'm using this code to add a rounded textfield to the alertcontroller:

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

However, the result is this:

enter image description here

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.

Thanks!

2

There are 2 answers

0
Francesco Scala On

try setting background color of UItextView to [UIColor clearColor]

0
yildirimosman On

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()
    }
}