UITextField in UIAlertController (border, backgroundColor)
here is the important part in swift:
for textfield: UIView in alertController.textfields {
var container: UIView = textField.superview
var effectView: UIView = container.superview.subviews[0]
container.backgroundColor = UIColor.clearColor()
effectView.removeFromSuperview()
}
Had some fun with this. The following seems to work. Obviously judging by what was required, it has no future proofing and is a patch away from not working.
I figured this out by walking the view hierarchy in the debugger, from which I noticed a UIVisualEffectView. Removing that seems to give you what you want along with setting the containing view to a clear background. Without removing the visual effect, a clear background shows what is behind the alert view itself for some reason.
UIAlertController *alertController =
[UIAlertController alertControllerWithTitle:@"Its Not Pretty!"
message:@"Some times things get ugly!"
preferredStyle:UIAlertControllerStyleAlert];
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField){
textField.text = @"Text: No border and clear 8^)";
}];
[self presentViewController:alertController animated:TRUE completion:^{
}];
for (UIView* textfield in alertController.textfields) {
UIView *container = textField.superview;
UIView *effectView = container.superview.subviews[0];
if (effectView && [effectView class] == [UIVisualEffectView class]){
container.backgroundColor = [UIColor clearColor];
[effectView removeFromSuperview];
}
}