1
私はカスタマイズされたUISearchBarを持っています。ユーザがsearchBarをクリックすると、追加のボタンを表示したいと思います。だから、私は追加のボタンを表示するscopeButtonTitlesプロパティを使用しています。しかし、それはUISearchBarには表示されません。カスタマイズされたUISearchBarにscopeButtonTitlesを実装する方法は?
customSearchController = CustomSearchController(searchResultsController: self, searchBarFrame: CGRect(x: 0.0, y: 0.0, width: tableView.frame.size.width, height: 50.0), searchBarFont: UIFont.systemFont(ofSize: 16.0), searchBarTextColor: UIColor.white, searchBarTintColor: UIColor.primaryBlue())
customSearchController.hidesNavigationBarDuringPresentation = false
customSearchController.dimsBackgroundDuringPresentation = false
customSearchController.customSearchBar.placeholder = NSLocalizedString("Search", comment: "Search")
customSearchController.customSearchBar.accessibilityLabel = customSearchController.searchBar.placeholder
//Scope Buttons
customSearchController.customSearchBar.scopeButtonTitles = [NSLocalizedString("List", comment: "List"), NSLocalizedString("Map", comment: "Map")]
カスタマイズしたUISearchBarを使用していない場合は問題ありません。実際の問題は、UISearchBarをカスタマイズするときです。
あなたの答えをありがとう、私はあなたのアプローチを試みた、それは働いている。しかし、それはUISearchBarと重複しており、最初は現れています。実際には、ユーザーが検索ボタンをクリックした後にのみ、追加のボタンを表示したいと考えています。また、私はUISearchBar CGRectの価値をハードコーディングしています。 – PradeshV
@PradeshV私の編集した答えを確認してください。 –
それは動作します:)ありがとう。 – PradeshV