UISearchBar放大镜图标在搜索栏之外

时间:2018-03-05 09:22:35

标签: ios swift uisearchbar

当搜索栏处于非活动状态且占位符太大时,放大镜图标会移到搜索栏之外。谁知道如何解决这个问题?没有 enter image description here

     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
    }()

1 个答案:

答案 0 :(得分:-1)

尝试按照本文中提到的UITextField附加UISearchBar来调整搜索栏图标的位置。 https://stackoverflow.com/a/36594565/2740582