firstly, you will find the preview in the UISearchBar , then find the UITextField in the preview, then change the color
Try this code: -
for(UIView *subView in searchBar.subviews){ if([subView isKindOfClass:UITextField.class]){ [(UITextField*)subView setTextColor:[UIColor blueColor]]; } }
for ios 5+
[[UITextField appearanceWhenContainedIn:[UISearchBar class], nil] setTextColor:[UIColor blueColor]];
Deepesh
source share