一、ios 13.0以上系统UIsearchBar 使用“ _searchField”崩溃修
解决方法:
if (@available(iOS 13.0, *)) {
searchField =[_searchBar valueForKey:@"_searchTextField"];
}else{
searchField = [_searchBar valueForKey:@"_searchField"];
}
二、ios 13系统中UITextField的Placeholder也就是占位文本的颜色和字体时更换了KVC的方法:
解决方法:
#在ios 13以上系统使用如下方法会有问题
[_textField setValue:[UIColor redColor] forKeyPath:@"_placeholderLabel.textColor"];
[_textField setValue:[UIFont systemFontOfSize:14] forKeyPath:@"_placeholderLabel.font"];
#可以将以上代码更换为以下方法:
_textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"测试" attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14],NSForegroundColorAttributeName:[UIColor redColor]}];
三、审核强制要求适配黑夜模式。
// 模式强制切换
if (darkMode) {
if (@available(iOS 13.0, *)) {
[UIApplication sharedApplication].keyWindow.overrideUserInterfaceStyle = UIUserInterfaceStyleDark;
}
} else {
if (@available(iOS 13.0, *)) {
[UIApplication sharedApplication].keyWindow.overrideUserInterfaceStyle = UIUserInterfaceStyleLight;
}
在 Info.plist 文件中,添加 key 为 User Interface Style,类型为 String,value 设置为 Light 可关闭黑暗模式。