[英]iOS 11: Add other nav items next to a search bar embedded in navigation item title view
您可以嘗試通過更改取消按鈕來實現此目的:
let searchController = UISearchController(searchResultsController: nil)
searchController.searchBar.showsCancelButton = true
if let view = searchController.searchBar.subviews.first {
for subview in view.subviews {
if let myButton = subview as? UIButton {
// setup button
myButton.setTitle("", for: .normal)
let image = UIImage(named: "myImage")
myButton.setBackgroundImage(image, for: .normal)
}
}
}
navigationItem.searchController = searchController
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.