views:

1098

answers:

2

I have a refresh button on my iphone screen that refreshes a table in the current view.

The screen refresh beautifully, but is there a way I can make the screen dim and then lighten again after the table has refreshed?

+1  A: 

Could you load a black, 50% alpha view over the top, possibly fade in?

Xetius
+6  A: 

You could place a non-opaque view with a black background over the view you wish to dim. This would have an alpha value of 0 by default and thus be transparent. You could then use a UIView animation to set the black views alpha from 0 to 0.5 (say) and then back.

Note: The code below has not been tested but I have used similar to achieve the same effect.

    ...
    dimView.alpha = 0.0f;
    [UIView beginAnimations@"fade" context:nil];
    [UIView setAnimationDuration:0.5f];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
    [UIView setAnimationRepeatAutoreverses:YES];
    dimView.alpha = 0.5f;
    [UIView commitAnimations];
    ...
}

- (void) animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
    dimView.alpha = 0.0f;
}
teabot
You said it much better than I did with code too.
Xetius
Neat. Let me try it.
Miriam Roberts
Thanks @Xetius!
teabot
I removed two lines of the code above to make it work that way I needed. Here is the final result: <p><pre><code> self.tableView.alpha = 0.0f; [UIView beginAnimations:@"fade" context:nil]; [UIView setAnimationDuration:0.5f]; [UIView setAnimationDelegate:self]; self.tableView.alpha = 1.0f; [UIView commitAnimations]; </code> </pre>
Miriam Roberts