I have a UISearchBar that I want to display when the user taps a button. In the buttonPress method, I create the searchBar and add it as a subview, then call [searchBar becomeFirstResponder]
. If I take out this becomeFirstResponder call, the search icon and placeholder text appear in the center of the textField.
Then, when the search bar becomes first responder, both animate to be left-aligned.
Because I'm doing both actions successively, I'm getting a weird animation where the icon & placeholder animate from (0,0).
How can I disable this animation, so that I can simply add the second image to my view?
EDIT:
I got the placeholder text to display correctly by using
- (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar
{
[searchBar setPlaceholder:@"Type Here to Search"];
}
I can move the search icon using [searchBar setPositionAdjustment:UIOffsetMake(x, y) forSearchBarIcon:UISearchBarIconSearch];
, but the changes are still applied within the animation.