更新时间:2023-02-03 09:03:31
这是适用于iOS 8和Swift的解决方案。
Here's a working solution for iOS 8 and Swift.
func enableCancleButton (searchBar : UISearchBar) {
for view1 in searchBar.subviews {
for view2 in view1.subviews {
if view2.isKindOfClass(UIButton) {
var button = view2 as! UIButton
button.enabled = true
button.userInteractionEnabled = true
}
}
}
}