2017-09-11 29 views
9

我從視圖控制器啓動CNContactPickerViewController,但是如何更改其中的搜索欄的textcolor。導航欄是深藍色,在iOS11中默認的searchbartext是黑色的。如何更改CNContactPickerViewController的顏色searchBar

+0

這是一個在iOS11 – RBN

+0

錯誤或新由於iOS的11現在已經出來了,我覺得這在iOS11中是新的,取決於應用程序的tintcolor。 – tmiedema

+1

我沒有找到一種方法來改變它保持黑色的搜索欄的文本顏色,但我設法改變背​​景顏色 [[UISearchBar appearance] setBackgroundColor:[UIColor whiteColor]]; –

回答

1

我更新的方式迅速 解決你目前CNContactPickerViewController之前,您應該設置的UISearchBar的背景顏色

  UISearchBar.appearance().backgroundColor = UIColor.white 
     let cancelButtonAttributes = [NSForegroundColorAttributeName: ColorConstant.baseColorGray] 
     UIBarButtonItem.appearance(whenContainedInInstancesOf: 
     [UISearchBar.self]).setTitleTextAttributes(cancelButtonAttributes, for: .normal)