I have an UISearchBar
, with search style "minimal", and I want to change the text color and to have a white border with 1px width
. I'm trying with tintcolor
but I don't get nothing
Thank you.
I have an UISearchBar
, with search style "minimal", and I want to change the text color and to have a white border with 1px width
. I'm trying with tintcolor
but I don't get nothing
Thank you.
To change the text color of the UISearchBar
, use this snippet
[[UITextField appearanceWhenContainedIn:[UISearchBar class], nil] setTextColor:[UIColor yourColor]];
For the white border, try this out
for (id object in [[[yourSearchBar subviews] objectAtIndex:0] subviews])
{
if ([object isKindOfClass:[UITextField class]])
{
UITextField *textFieldObject = (UITextField *)object;
textFieldObject.textColor = [UIColor redColor];
textFieldObject.layer.borderColor = [[UIColor whiteColor] CGColor];
textFieldObject.layer.borderWidth = 1.0;
break;
}
}
Hope this helps!
Edit
You can add the first line for the search bar color anywhere in your app. Also, I have added one line for the textColor
in the loop, check that out.