I'm trying out some designs and I'd like to have an equal 25px margin for all my subviews. UISearchController's searchBar has a 16px padding on either sides out of the box. Do I have to write the search bar textfield from scratch, or is there ANY way, undocumented, swizzling, or otherwise, to accomplish offsetting the native bar to my taste?

If you are using a UISearchController you can set the margins of the searchBar like this (assuming searchBar is the UISearchController instance):
let directionalMargins = NSDirectionalEdgeInsets(top: 0, leading: 25, bottom: 0, trailing: 25)
searchController.searchBar.directionalLayoutMargins = directionalMargins
                        For UISearchBar text position use:
searchBar.searchTextPositionAdjustment = .init(horizontal: 25, vertical: 0)
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With