UISearchBar: changing background color of input field

前端 未结 5 1810
夕颜
夕颜 2020-12-19 07:05

I\'m trying to change the background color of input field of UISearchBar.It\'s the rounded view where you input text to search, the default color is white. I would like to c

5条回答
  •  不思量自难忘°
    2020-12-19 07:39

    Solution in Swift 3:

    if let txfSearchField = searchController.searchBar.value(forKey: "_searchField") as? UITextField {
            txfSearchField.borderStyle = .none
            txfSearchField.backgroundColor = .lightGray
    }
    

提交回复
热议问题