我仍然是新手,不知道如何像照片一样构建此自定义NavigationController。
let searchController = UISearchController(searchResultsController: nil)
override func viewDidLoad() {
super.viewDidLoad()
self.navigationController?.isNavigationBarHidden = false
setupNavigationBarItems()
searchNavBar()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
}
func setupNavigationBarItems() {
let titleImageView = UIImageView(image: #imageLiteral(resourceName: "Logo"))
navigationItem.titleView = titleImageView
navigationItem.hidesBackButton = true
}
func searchNavBar() {
navigationItem.searchController = searchController
searchController.searchBar.delegate = self
searchController.searchBar.placeholder = "like name, address or tags"
let textFieldInsideSearchBar = searchController.searchBar.value(forKey: "searchField") as? UITextField
textFieldInsideSearchBar?.backgroundColor = UIColor.white
}
func searchBar (_ searchBar: UISearchBar, textDidChange searchText: String){
print(searchText)
}
如何正确构建它?