UISearchBar Cancel Button

前端 未结 6 2783
别那么骄傲
别那么骄傲 2021-02-20 03:35

Using a UISearchBar with showCancelButton=YES on iOS 5. Would like the cancel button to stay enabled when the keyboard drops down. Using the following code seems not to work:<

6条回答
  •  情话喂你
    2021-02-20 04:32

    Swift 5:, Swift 4:

    if let btnCancel = searchBar.value(forKey: "cancelButton") as? UIButton {
        btnCancel.isEnabled = true
    }
    

提交回复
热议问题