p0l*_*ris 12 uitextfield ios uialertcontroller
这是一个截图UIAlertController.我只是在玩自定义字体和textfield属性,但我无法完成以下任务:
UITextField
当我更深入地研究代码和iOS运行时标题时,我能够修改边框和背景颜色,但上述问题仍然存在,因为这些属性属于容器UITextView.改变背景clearColor并没有帮助.
有没有人玩过这个?不确定我是否会将这些丑陋的文本字段用于生产我的应用程序.
编辑(5月13日,15日)以下答案由Rory McKinnel测试iOS 8 - 8.3并且工作得很好.结果如下:

Ror*_*nel 18
对此有一些乐趣.以下似乎有效.显然,根据需要判断,它没有未来的证据,是一个远离不工作的补丁.
我通过在调试器中遍历视图层次结构来解决这个问题,我注意到了UIVisualEffectView.删除它似乎可以为您提供所需的内容,并将包含视图设置为清晰的背景.在不删除视觉效果的情况下,清晰的背景会出于某种原因显示警报视图背后的内容.
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];
}
}
Run Code Online (Sandbox Code Playgroud)
这是 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()
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6377 次 |
| 最近记录: |