更改搜索栏中的文本框对齐方式

问题描述 投票:0回答:1

我想在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)

}

如何在搜索栏中使用文本对齐方式?

ios swift uisearchbar uisearchcontroller
1个回答
0
投票

您可以参考此link来更改搜索栏中占位符的对齐方式。

但我建议使用UITextField和UIImageView创建自己的搜索栏,并响应委托调用。

© www.soinside.com 2019 - 2024. All rights reserved.