最佳答案
试试这个 您可以通过 UISearchBar Delegate 方法禁用取消按钮。
func searchBarTextDidBeginEditing(searchBar: UISearchBar) {
searchBar.setShowsCancelButton(false, animated: false)
}
func searchBarTextDidEndEditing(searchBar: UISearchBar) {
searchBar.setShowsCancelButton(false, animated: false)
}
如果您使用的是 CustomSearchBar
自定义搜索栏.swift
import UIKit
class CustomSearchBar: UISearchBar {
override func layoutSubviews() {
super.layoutSubviews()
setShowsCancelButton(false, animated: false)
}
}
关于ios - GMSAutocompleteViewController 删除 "cancel"按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60068872/