Removing the image on the left of an UISearchbar

前端 未结 17 1847
攒了一身酷
攒了一身酷 2020-12-29 20:44

Can I remove the image on the left of an UISearchbar and add a new image?

17条回答
  •  一个人的身影
    2020-12-29 21:23

    Swift 4 solution:

    searchBar.setImage(UIImage(), for: .search, state: .normal)
    

    You probably also want to adjust the gap on the left side:

    searchBar.setPositionAdjustment(UIOffset(horizontal: -20, vertical: 0), for: .search)
    

提交回复
热议问题