So here are a couple of tricks to make your Search Bar stand out
1. Making the search bar hide behind the top bar and pulling it out when required : All you have to do is this
/* Offset your view in the -(void) viewWillAppear method by 44.0f i.e. the height of your search bar and you are done. Yea am neither joking nor drunk. */
-(void) viewWillAppear: (BOOL) animated{
self.tableView.contentOffset=CGPointMake(0.0, 44.0f);
}
1. Making the search bar hide behind the top bar and pulling it out when required : All you have to do is this
/* Offset your view in the -(void) viewWillAppear method by 44.0f i.e. the height of your search bar and you are done. Yea am neither joking nor drunk. */
-(void) viewWillAppear: (BOOL) animated{
self.tableView.contentOffset=CGPointMake(0.0, 44.0f);
}
2. This one is my fav. This effect makes the search bar stick to the top bar like in the Game Center so that it doesn't scroll down along with the table.
/* For this we have to override the -(void) scrollViewDidScroll(UIScrollView *) scrollView method and add to it a simple logic driven code*/
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
//Getting the rectangle that is the boundary of the search bar
CGRect rect = searchBar.frame;
//Setting the origin of the frame to always be 0. Magic right??!!
rect.origin.y = MIN(0, scrollView.contentOffset.y);
searchBar.frame = rect;
}