AckeeCZ / ACKategories

Swift tools, cocoa subclasses and extensions.
MIT License
56 stars 13 forks source link

iOS 13 revealed `textField` on `UISearchBar` #57

Closed olejnjak closed 4 years ago

olejnjak commented 4 years ago

So we can use it natively instead of our hack 🎉

https://github.com/AckeeCZ/ACKategories/blob/1bc672b0c2b28fb635bb5a972e86f3615707c5de/ACKategories/UISearchBarExtensions.swift#L5

janmisar commented 4 years ago

But only for 13+ 😬 Removal is breaking change which is not good so I suggest just to deprecate this and we're done.

olejnjak commented 4 years ago

I think that the same approach as view use for view.safeArea is optimal, at least for now.

https://github.com/AckeeCZ/ACKategories/blob/1bc672b0c2b28fb635bb5a972e86f3615707c5de/ACKategories/UIView%2BSafeAreaCompat.swift#L22

olejnjak commented 4 years ago

Finally implemented in #61 in a bit different way as @LukasHromadnik suggested. The implementation is as discussed here, it uses searchTextField on iOS 13+, on older systems it uses the old value(forKey:) method.

In addition it is marked to be deprecated on iOS 13+, so it reports a deprecation warning if deployment target is iOS 13+ (we should do this also for the UIView.safeArea), otherwise it compiles without any warning.