简体   繁体   English

iOS 13 UISearchController 书签

[英]iOS 13 UISearchController Bookmark

In iOS 13 my custom UISearchController bookmark image stretches and is not sizing to fit properly.在 iOS 13 中,我的自定义 UISearchController 书签图像拉伸并且尺寸不合适。

In iOS 12.x the image fits nicely in the search bar:在 iOS 12.x 中,图像非常适合搜索栏:

iOS 12 图片

But in iOS 13 I get the below look:但在 iOS 13 中,我得到以下外观:

iOS 13 图片

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.我尝试将 searchBar 的 contentMode 和所有子视图设置为 .scaleAspectFit 但没有运气。 I also tried looping through all the subviews looking for UIButton but didn't find it.我还尝试遍历所有子视图以查找 UIButton 但没有找到。

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.在 iOS 12 中,图像正在调整大小以适合,但在 iOS 13 中,情况并非如此。 Adding proper 1x, 2x, and 3x sizes resolved the issue.添加适当的 1x、2x 和 3x 尺寸解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM