[英]UIAlertView's UIAlertViewStylePlainTextInput custom font doesn't work in iOS
我必须在iOS应用程序的UIAlertView's
UIAlertViewStylePlainTextInput
中使用自定义字体。
我的代码不起作用。
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Create New Folder" message:@"Please enter folder name." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"Create", nil];
alert.tag = 1;
alert.alertViewStyle = UIAlertViewStylePlainTextInput;
[alert textFieldAtIndex:0].font = [UIFont fontWithName:@"MyCustomFont" size:15];
[alert show];
如何在UIAlertView
textField中使用自定义字体?
您无法自定义警报视图的外观,因为它已被Apple设为私有。 请参考链接https://developer.apple.com/library/ios/documentation/uikit/reference/UIAlertView_Class/UIAlertView/UIAlertView.html中的子类注释。
在iOS> 7.0中,您无法更改UIAlertView
的外观,因为它的视图层次结构是私有的。
官方文件说:
UIAlertView
类旨在按原样使用,不支持子类。 此类的视图层次结构是私有的,不能修改 。
因此,无法更改字体。
希望这可以帮助.. :)
在iOS 7.x之后,您无法自定义警报视图的外观,因为其视图层次结构是私有的。
在UIAlertView类参考中明确提到了它:
UIAlertView类旨在按原样使用,不支持子类。 此类的视图层次结构是私有的, 不能修改 。
无法更改textField字体,按钮文本颜色等。
唯一的解决方案是使用自定义UIAlertView之一。 就像
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.