In iOS 13 my custom UISearchController bookmark image stretches and is not sizing to fit properly.
In iOS 12.x the image fits nicely in the search bar:
But in iOS 13 I get the below look:
The image is being set the same way in both versions (same version of the app running on both devices)
DispatchQueue.main.async {[weak self] in
self?.txtSearchBar.setImage(UIImage(named: "barcode_image"), for: .bookmark, state: .normal)
}
I've tried setting the contentMode of the searchBar and all subviews to.scaleAspectFit but no luck. I also tried looping through all the subviews looking for UIButton but didn't find it.
This turned out to be due to the image size.
In iOS 12 the image was being resized to fit but in iOS 13 that was not the case. Adding proper 1x, 2x, and 3x sizes resolved the issue.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.