我有一个汉堡包菜单,我正在使用tableView显示一个viewController。问题是我已经在titleView中添加了一个UISearchBar,你可以看到一些searchBar正在隐藏。有没有办法可以让navigationBar更小或者搜索栏更适合?
答案 0 :(得分:1)
searchBar = UISearchBar(frame: CGRectMake(0, 0, self.revealViewController().rearViewRevealWidth-30, 44))
searchBar?.delegate = self
searchBar?.showsCancelButton = false
var textField = searchBar?.valueForKey("searchField") as UITextField
textField.backgroundColor = UIColor(rgba: "#414e5c")
textField.leftViewMode = UITextFieldViewMode.Never
textField.layer.cornerRadius = 5
textField.clipsToBounds = true
searchBar?.placeholder = "Søg efter produkter"
searchBar?.setPositionAdjustment(UIOffsetMake(0, 0), forSearchBarIcon: UISearchBarIcon.Search)
textField.borderStyle = UITextBorderStyle.None
searchController = UISearchDisplayController()
searchController?.delegate = self
searchController?.searchResultsDelegate = self
var buttonSearchBar:UIBarButtonItem = UIBarButtonItem(customView: searchBar!)
self.navigationItem.leftBarButtonItem = buttonSearchBar