xcode 更改searchBar占位符文本对齐到左侧iOS swift
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37179371/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 08:48:35 来源:igfitidea点击:
changing searchBar Placeholder text Alignment to left iOS swift
提问by Sajjad Aims
here is the code for my 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
})()
when i click on search bar the code becomes left align but before that it is always scattered
当我点击搜索栏时,代码变为左对齐,但在此之前它总是分散的
采纳答案by Ketan Parmar
You can use whitespaceto achieve this!!
你可以用它whitespace来实现!!
let searchBar: UISearchBar = UISearchBar() //your searchbar
searchBar.placeholder = "Search "
Hope this will help :)
希望这会有所帮助:)

