如何将UISearchBar图标更改为自定义图像? [英] How to change UISearchBar Icon to custom image?
本文介绍了如何将UISearchBar图标更改为自定义图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
目前,我使用默认放大镜作为搜索栏图标。但是,我想在其位置放置自定义图像,尤其是此图像:自定义箭头图标
Currently, I have the default magnifying glass as my search bar icon. However, I want to put a custom image in its place, particularly this image: Custom Arrow Icon
如何将搜索栏默认图标更改为自定义图像?
How would I go about changing the search bar default icon to the custom image?
推荐答案
你可以使用 setImage
function
you can use setImage
function
searchBar.setImage(UIImage(named: "your image"), forSearchBarIcon: .Search, state: .Normal)
Swift3
searchBar.setImage(UIImage(named: "Image Name"), for: .search, state: .normal)
这篇关于如何将UISearchBar图标更改为自定义图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文