[英]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.