【问题标题】:How to insert UISearchBar under NavigationBar Title如何在 NavigationBar 标题下插入 UISearchBar
【发布时间】:2016-08-24 16:10:55
【问题描述】:

谁能帮我解决这个问题?

我希望在导航栏内放置一个搜索栏,但在标题下(这样做的原因是我想要一个导航栏和搜索栏的图像)导航栏的

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

【问题讨论】:

    标签: ios swift uinavigationbar uisearchbar


    【解决方案1】:

    您需要将自定义视图添加到您的导航栏并使其居中。

    也许这可以帮助你:

    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/

    【讨论】:

    • @david 对你有帮助吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-23
    • 2018-09-04
    相关资源
    最近更新 更多