2017-07-26 93 views
0

代碼呈現呈現SearchController:UISearch酒吧提示與狀態欄重疊而作爲UISearchController

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) 

enter image description here

回答

0

我覺得你storageLocation間距頂端爲-20。當你在故事板中設置你的約束時,不要擔心頂部的填充(即使你設置0間距),這是狀態欄。

選項:

  • 集storageLocation頂間距爲0,而不是-20

  • 隱藏狀態欄

要隱藏狀態欄,將其包含在VC的底部:

override var prefersStatusBarHidden: Bool { 
     return true 
    } 

在你的info.plist中用YES設置一個鍵「UIRequiresFullScreen」。

在項目設置 - >目標 - >通用(你設置你的應用程序名稱,捆綁標識符,籤售等),在部署信息,確保「隱藏狀態欄選擇」