【问题标题】:UISearch Bar prompt overlaps with status bar while presenting as UISearchControllerUISearch Bar 提示在显示为 UISearchController 时与状态栏重叠
【发布时间】:2017-07-26 08:20:44
【问题描述】:

展示 SearchController 的代码:

searchController = UISearchController(searchResultsController:viewcontroller) 
storageLocation.tableView.tableHeaderView = searchController.searchBar
searchController.dimsBackgroundDuringPresentation = true
searchController.hidesNavigationBarDuringPresentation = true
searchController.searchBar.prompt = "Some random text"
self.definesPresentationContext = true 
searchController.searchBar.backgroundColor = .white 
self.present(searchController, animated: true, completion: nil)

【问题讨论】:

    标签: swift xcode8 ios10 uisearchcontroller


    【解决方案1】:

    我认为您的 storageLocation 到顶部的间距是 -20。当您在情节提要中设置约束时,不要对顶部的填充(即使您设置 0 间距)感到震惊,那是状态栏。

    选项:

    • 将 storageLocation 顶部间距设置为 0 而不是 -20

    • 隐藏状态栏

    要隐藏状态栏,请在 VC 底部添加:

    override var prefersStatusBarHidden: Bool {
            return true
        }
    

    在你的 info.plist 中设置一个键“UIRequiresFullScreen”为 YES。

    在您的项目设置 -> 目标 -> 常规(您在其中设置应用名称、捆绑标识符、签名等)中,在部署信息中,确保“选择隐藏状态栏”

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多