In iOS7 the search icon and place holder text are always appearing in middle.I tried changing the text alignment of the text field in search bar to left but it didn\'t work.
[self setBackgroundColor:[UIColor clearColor]];
[self setTextAlignment:NSTextAlignmentLeft];
[self setContentVerticalAlignment:UIControlContentVerticalAlignmentCenter];
[self setAutocorrectionType:UITextAutocorrectionTypeNo];
[self setAutocapitalizationType:UITextAutocapitalizationTypeNone];
[self setPlaceholder:@"Search"];
[self setLeftView:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"search-icon"]]];
[self setLeftViewMode:UITextFieldViewModeAlways];
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
NSString* searchString = [textField.text stringByReplacingCharactersInRange:range withString:string];
searchYourFriendsArray = [[NSMutableArray alloc] init];
if(searchString.length > 0 )
{
NSMutableArray *searchArray = [NSMutableArray arrayWithArray:yourFriendsArray];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"FirstName beginswith[C] %@ OR LastName beginswith[C] %@",searchString,searchString];
searchYourFriendsArray = [NSMutableArray arrayWithArray:[searchArray filteredArrayUsingPredicate:predicate]];
}
return YES;
}