当搜索栏处于非活动状态且占位符太大时,放大镜图标会移到搜索栏之外。谁知道如何解决这个问题?什么都没有
lazy var searchBar: UISearchBar = {
let searchBar = UISearchBar()
searchBar.autocorrectionType = .yes
searchBar.autocapitalizationType = .none
searchBar.placeholder = ChangeToLanguage(SEARCH_LABEL_PLACEHOLDER_SEARCHMODULES)
searchBar.delegate = self
searchBar.isTranslucent = false
let searchBarTextField = searchBar.value(forKey: "searchField") as? UITextField
searchBarTextField?.tintColor = GlobalTintColor
searchBar.barTintColor = GlobalTintColor
return searchBar
}()
尝试通过抓住附在UITextField
上的UISearchBar
调整搜索栏图标的位置,如本文所述。 https://stackoverflow.com/a/36594565/2740582