However, I've applied different patches still I'm not able to fix placeholder text position and text color for UISearchbar
.
But when I type something, it's showing up at a proper place.
What's the reason?
However, I've applied different patches still I'm not able to fix placeholder text position and text color for UISearchbar
.
But when I type something, it's showing up at a proper place.
What's the reason?
This is how you can change the colour of your placeholder text:
UITextField *searchField = [self.searchBar valueForKey:@"searchField"];
searchField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"Some Text"];
UILabel *placeholderLabel = [searchField valueForKey:@"placeholderLabel"];
placeholderLabel.textColor = [UIColor blueColor];
As for the position, by default, placeholder text is vertically centre positioned in the UISearchBar
. From your screenshot, it appears to me that there are few new line characters in the end of the text.
there's a category created on UITextField
, inside it, the placeholder text is drawing. I just corrected the frame and now everything works fine, even that solve the color issue as well.