最大的坑还是iOS13系统不让 KVC 的方式 来取或修改一些私有属性,目前是遇到 UISearchBar 的坑,其他还在测试中。
crash修复
2019.06.04 下载了Xcode_11_Beta,跑起来项目后,直接crash。
原本 searchbar 的样子:

生成 UISearchBar 的代码:
1  | - (void)initSearchBar  | 
crash原因:
1  | *** Terminating app due to uncaught exception 'NSGenericException', reason: 'Access to UISearchBar's _searchField ivar is prohibited. This is an application bug'  | 
问题代码:
1  | UITextField *textField = [self.searchBar valueForKey:@"_searchField"];  | 
看来iOS13不允许用 valueForKey 来取私有属性。那就改成遍历取值:
1  | UITextField *textField = (UITextField*)[self.searchBar findSubview:@"UITextField" resursion:YES];  | 
findSubview:resursion 是 UIView 的自定义分类实现的方法,实现为:
1  | - (UIView *)findSubview:(NSString *)name resursion:(BOOL)resursion  | 
然后再跑,接着crash。
1  | *** Terminating app due to uncaught exception 'NSGenericException', reason: 'Access to UITextField's _placeholderLabel ivar is prohibited. This is an application bug'  | 
1  | [textField setValue:[UIColor colorWithRGBHex:0x000000 alpha:0.35] forKeyPath:@"_placeholderLabel.textColor"];  | 
给 textField 设置 placeholder 字体颜色也不行了,这就很尴尬。
原本设置placeholder的方法:
1  | - (void)setPlaceholderStr:(NSString *)placeholderStr  | 
只好改为设置 UITextField 的 @property(nullable, nonatomic,copy)   NSAttributedString     *attributedPlaceholder API_AVAILABLE(ios(6.0)); // default is nil 属性。
1  | - (void)setPlaceholderStr:(NSString *)placeholderStr  | 
至此,crash修复了。
背景色重叠问题
但是searchBar的背景色又出了问题。

看了下层级是 _UISearchBarSearchFieldBackgroundView ,尝试这个方案:
1  | UIView *textFieldBackgroundView = (UIView *)[self.searchBar findSubview:@"_UISearchBarSearchFieldBackgroundView" resursion:YES];  | 
失败。取出来是nil。尝试另一种方案:
1  | for (UIView *view in self.searchBar.subviews) {  | 
干是干掉了,但是直接crash了:
1  | *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Missing or detached view for search bar layout'  | 
看来干掉后系统布局找不到这个view就挂了。
最后在layoutUI 布局的方法里面设置一下image
1  | - (void)layoutUI  | 
但这就出现了以前遇到的问题,searchbar的背景色通过设置 self.searchBar.barTintColor 来搞定的。但这样上下就会有条黑线:

改成设置backgroundImage。
1  | [self.searchBar setBackgroundImage:[UIImage imageWithColor:[UIColor colorWithRGBHex:0xF1F3F6]]];  | 
最后代码整体改为:
1  | - (void)initSearchBar  | 
适配结束。
总结
- 最大的坑还是iOS13系统不让 KVC 的方式 来取或修改一些私有属性,目前是遇到 
UISearchBar的坑,其他还在测试中。 UISearchBar的背景色,内部UITextField的背景色,这几个设置起来都是组合比较多,坑也比较多。