我想在Searchcontroller searchBar中更改Placeholder的文本对齐方式。
我使用这个Swift代码在我的导航控制器中创建搜索栏:
@IBAction func searchwithAddress(_ sender: Any) {
let searchController = UISearchController(searchResultsController: searchResultController)
searchController.searchBar.delegate = self
searchController.obscuresBackgroundDuringPresentation = false
searchController.searchBar.becomeFirstResponder()
definesPresentationContext = true
self.present(searchController, animated: true, completion: nil)
}
如何在搜索栏中使用文本对齐方式?
您可以参考此link来更改搜索栏中占位符的对齐方式。
但我建议使用UITextField和UIImageView创建自己的搜索栏,并响应委托调用。