 <pre><code> for view in (UISearchBar.subviews[0]).subviews{ if let button = view as? UIButton{ button.setTitleColor(UIColor.whiteColor(), forState: .Normal) button.setTitle("Cancel", forState:.Normal) } } </code></pre> <p>self.subviews[0]).subviews contain UISearchBarBackground,UISearchBarTextField,UINavigationButto‌​n in which UINavigationButton is subclass of UIButton.Check for View as UIButton and if yes then change property of UIButton.</p>