2015-01-08 2 views
2

iOS 8의 UISearchBar 안의 취소 버튼의 텍스트 글꼴과 색상을 변경하고 싶습니다. iOS 6 및 7 용 솔루션을 이미 시도했지만 작동하지 않는 것 같습니다.UISearchBar에서 UIBarButtonItem 변경

+0

당신은 당신이 무엇을 시도했다 우리를 게재 할 수 있습니까? – Emil

답변

5

이것은 내가 찾던 해결책이 아니었지만 효과가있었습니다.

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

그러나 우리는 주제에 있지만이 또한 유용하다 :

let cancelButtonAttributes: NSDictionary = [NSFontAttributeName: FONT_REGULAR_16!, NSForegroundColorAttributeName: COLOR_BLUE] 
UIBarButtonItem.appearance().setTitleTextAttributes(cancelButtonAttributes, forState: UIControlState.Normal) 
+0

이 작품 !!!!!! –

+0

감사합니다. –

+0

이것은 나를 위해 또한 일하고있다. font 속성 및 상수를 제거한 swift 2의 부 개정. - 은 cancelButtonAttributes을 보자있는 NSDictionary = [NSForegroundColorAttributeName : UIColor.blackColor()] UIBarButtonItem.appearance() setTitleTextAttributes (같은 cancelButtonAttributes [문자열 : AnyObject, forState : UIControlState.Normal?) – ekill

0

당신이 찾고있는 무엇이다

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() 
관련 문제