views:

273

answers:

1

Many of the table searches I see actually dim (change alpha?) of the actual tableView when the search bar gets focused. I am trying to implement this.

When I overload

- (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar

I am trying to do something like

self.tableView.alpha = .5f

But it is changing the alpha of the actual searchBar (if I have searchBar on its own) or changing the alpha of the entire table (including searchBar) if I have searchBar underneath the tableView in IB.

What am I doing wrong here. How can I just Dim the table and not everything.

I guess what I am really failing to understand is how all this stuff gets layered on the screen.

EDIT: The contacts application is a good example of what I am trying to do.

+1  A: 

Most such apps just throw a black-background UIView on top of the table and fade it in (to an alpha of .5 or whatever) when the search bar gains focus.

Noah Witherspoon
Can you post some quick example code?
jr
[UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.5f]; UIView *blackView = [[UIView alloc] initWithFrame:CGRectMake(something)]; [myTableView addSubview:blackView]; [UIView commitAnimations];
chpwn