Hiding Cancel button on search bar in UISearchController

前端 未结 6 880
离开以前
离开以前 2020-12-07 02:08

I\'m trying to hide the Cancel button of the search bar in the UISearchController, but unfortunately setting the following in viewDidLoad() does not work:

ov         


        
6条回答
  •  余生分开走
    2020-12-07 02:41

    Try subclassing UISearchBar and implement:

    override func layoutSubviews() {
       super.layoutSubviews()
       self.setShowsCancelButton(false, animated: false)
    }
    

    This SO thread may help you more in this direction.

提交回复
热议问题