Change UIBarButtonItem from UISearchBar

后端 未结 2 391
醉梦人生
醉梦人生 2020-12-12 02:48

I\'d like to change the text font and color of the Cancel button inside the UISearchBar in iOS 8. I\'ve tried the solutions for iOS 6 and 7 already and they don\'t seem to w

2条回答
  •  离开以前
    2020-12-12 03:05

    What you are looking for is:

    //The tintColor below will change the colour of the cancel button
    searchBar.tintColor = UIColor.blueColor()
    

    But these are also useful While we are on the subject:

    searchBar.placeholder = "Placeholder"
    //The barTintColor changes the colour of the flashing text indicator
    searchBar.barTintColor = UIColor.redColor()
    //This sets the cancel button to show up
    searchBar.setShowsCancelButton(true, animated: true)
    //This makes the searchBar become active 
    searchBar.becomeFirstResponder()
    

提交回复
热议问题