2
我嘗試更改searchController.searchBar的大小和位置,例如 我將y從0增加到100,但我可以在程序中看到任何更改。如何更改searchController的大小和位置?.searchBar?
這裏是我的代碼:
placesClient = GMSPlacesClient.sharedClient()
resultsViewController = GMSAutocompleteResultsViewController()
resultsViewController?.delegate = self
searchController = UISearchController(searchResultsController: resultsViewController)
searchController?.searchResultsUpdater = resultsViewController
searchController?.searchBar.sizeThatFits(CGSize(width: 600, height: 44.0))
self.definesPresentationContext = true
searchController?.searchBar.frame = (CGRectMake(0, 100,600, 44.0))
self.navigationItem.rightBarButtonItem = UIBarButtonItem(customView: (searchController?.searchBar)!)
// Keep the navigation bar visible.
searchController?.hidesNavigationBarDuringPresentation = false
searchController?.modalPresentationStyle = UIModalPresentationStyle.Popover
任何機構可以幫助我嗎?