【发布时间】:2017-01-24 14:24:15
【问题描述】:
我有一个自定义的 UISearchBar,当用户点击 searchBar 时,我想显示一个额外的按钮。所以,我使用 scopeButtonTitles 属性来显示附加按钮。但是,它没有出现在 UISearchBar 上。
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 时。
【问题讨论】:
标签: ios swift swift3 uisearchbar uisearchcontroller