如何制作自定义NavigationController

时间:2019-05-28 14:40:55

标签: ios swift

我仍然是新手,不知道如何像照片一样构建此自定义NavigationController。

enter image description here

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)
}

如何正确构建它?

0 个答案:

没有答案