这是我的searchBar的代码
self.searchResultsController = ({
let controller = UISearchController(searchResultsController: nil)
controller.searchResultsUpdater = self
controller.dimsBackgroundDuringPresentation = false
controller.hidesNavigationBarDuringPresentation = false
controller.searchBar.sizeToFit()
controller.searchBar.placeholder = "Type your word here"
//dcontroller.view.backgroundColor = UIColor.blackColor()
controller.searchBar.barTintColor = UIColor.blackColor()
self.tableVw.tableHeaderView = controller.searchBar
return controller
})()
当我点击搜索栏时,代码变为左对齐但在此之前它始终是分散的
答案 0 :(得分:-7)
您可以使用whitespace
来实现此目标!
let searchBar: UISearchBar = UISearchBar() //your searchbar
searchBar.placeholder = "Search "
希望这会有所帮助:)