iOS 13

iOS 13适配的坑(持续更新)

2019-06-10  本文已影响167人  庄msia

一. UISearchBar

UISearchBar的 _searchField 私有属性去掉了, 但它的getter searchBarTextField 还在,可以用KVC获取到

[self valueForKey:@"searchBarTextField"]

而且新增加了一个 searchTextField 方法获取UISearchTextField对象(是的UISearchTextField公开了, 两个方法名只差了一个Bar, 苹果有必要这样吗),然而searchTextField方法没有标记iOS13, 估计是苹果忘了, 或者改错名字了, searchBarTextField和searchTextField获取到的是同一个对象

同时UITextField的私有属性_placeholderLabel被禁止访问了,用kvc获取会报错:
exception: Access to UITextField's _placeholderLabel ivar is prohibited. This is an application bug
但可以用

[searchField performSelector:@selector(_placeholderLabel)]获取到

UISearchTextField多了一层backgroundView, 默认灰色圆角, 而且还不能改, 去掉的方法是:

[self.searchTextField performSelector:@selector(_clearBackgroundViews)];

_clearBackgroundViews这个方法从iOS8就有了

上一篇下一篇

猜你喜欢

热点阅读