谁能帮我这个?

我想将searchBar放置在navigationBar内,但是在Title下(这样做的原因是我想要一张用于NavigationBar和SearchBar的图像)NavigationBar的

func createSearchBar()
{
    let searchBar = UISearchBar()
    searchBar.showsCancelButton = false
    searchBar.placeholder = "Search"
    searchBar.delegate = self
    self.navigationItem.titleView = searchBar
}

最佳答案

您需要在导航栏的中心添加自定义视图。

也许这可以帮助您:

Can't set titleView in the center of navigation bar because back button

或创建自定义导航栏:

https://www.codeschool.com/blog/2014/11/11/ios-app-creating-custom-nav-bar/

关于ios - 如何在NavigationBar标题下插入UISearchBar,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39128270/

10-09 16:16
查看更多