검색 모음에 검색 모음을 추가했으며 텍스트와 배경색을 변경하려고합니다. 나는 아래 코드를 사용하고 있으며 SO appearanceWhenContainedIn
에 대한 다른 답변을 바탕으로 작동하지만 아무것도하지 않습니다. 여기서 뭐가 잘못 됐어? 코드 조각 다음탐색 모음에서 검색 모음의 텍스트와 배경색을 변경할 수 없습니다.
UISearchBar * theSearchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0,0,320,40)]; // frame has no effect.
theSearchBar.delegate = self;
if (!searchBarPlaceHolder) {
searchBarPlaceHolder = @"What are you looking for?";
}
theSearchBar.placeholder = searchBarPlaceHolder;
theSearchBar.showsCancelButton = NO;
[[UITextField appearanceWhenContainedIn:[UISearchBar class], nil] setTextColor:[UIColor redColor]];
UISearchDisplayController *searchCon = [[UISearchDisplayController alloc]
initWithSearchBar:theSearchBar
contentsController:self ];
[searchCon setActive:NO animated:YES];
self.searchDisplayController = searchCon;
self.searchDisplayController.delegate = self;
self.searchDisplayController.searchResultsDataSource = self;
self.searchDisplayController.searchResultsDelegate = self;
self.searchDisplayController.displaysSearchBarInNavigationBar=YES;
이 정보는 도움이됩니다. 배경색은 변경할 수 있지만 텍스트 색상은 변경할 수 없습니다. 나는 tintColor와 setTintColor를 시도했다. 어떤 제안? – Ryasoh