当我将 UISearchController 搜索栏中的占位符文本更新为比搜索栏更宽的内容时,搜索图标会发生这种情况:

ios - UISearchController 中的搜索图标被截断-LMLPHP

我通过在 viewDidLoad 中调用以下方法添加了 UISearchController 和搜索栏:

private func initSearchController() {

    searchResultsController = UITableViewController()
    searchResultsController.tableView.backgroundColor = UIColor(red: 51/255, green: 51/255, blue: 51/255, alpha: 1.0)
    searchController = UISearchController(searchResultsController: searchResultsController)
    searchResultsController.tableView.rowHeight = 50

    let textFieldInsideSearchBar = searchController.searchBar.valueForKey("searchField") as? UITextField
    textFieldInsideSearchBar?.textColor = UIColor.whiteColor()
    searchController.searchBar.sizeToFit()
    searchController.searchBar.placeholder = "SOL Southwest Kitchen & Tequila Bar"

    searchController.hidesNavigationBarDuringPresentation = false
    searchController.dimsBackgroundDuringPresentation = true
    searchController.searchBar.searchBarStyle = .Minimal
    navigationItem.titleView = searchController.searchBar
    definesPresentationContext = true

    searchController.searchResultsUpdater = self
    searchResultsController.tableView.dataSource = self
    searchResultsController.tableView.delegate = self
    searchController.searchBar.delegate = self

}

是什么赋予了?另外,无论如何要消除后退按钮和搜索栏之间的奇怪间隙?如果有帮助,这个 View 是导航 Controller 中的第二个 View Controller 。使用 iOS9 和 Swift 2.1。谢谢!

最佳答案

除非使用按钮、图像和文本字段创建自定义搜索栏,否则这似乎是不可能的。

关于ios - UISearchController 中的搜索图标被截断,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33832463/

10-14 22:12
查看更多