tags:

views:

72

answers:

3

I want to make an overlay which is partially transparent, and covers the entire screen including the status bar. I've seen that the folks at tapbots do exactly that. So it must be possible somehow. Status bar should still be visible!

A: 

Before iPhoneOS 3.2:

[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];

after iPhoneOS 3.2:

[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation: UIStatusBarAnimationNone];

For more information on these, see the documentation for UIApplication.

Jason Coco
this hides the status bar. But I want it to stay there, and cover it!
dontWatchMyProfile
How do you know it's still there if it's covered?
Rob Lourens
Oh, you want the view to be partially transparent, I see.
Rob Lourens
Jason reread the question, he wants the Status bar to visible through the semi transparent view.
Jonathan
@mystify: in that case, you would change the status bar's style to black-translucent. You are not supposed to cover the status bar. That said, you can always put your view in the actual window and make sure that it is the very top view (order it front and adjust its position). You may end up getting your application rejected, however.
Jason Coco
A: 

There are two ways to hide the status bar:

Programaticaly at runtime by using UIApplication sharedApplication:

- (void)setStatusBarHidden:(BOOL)hiddenwithAnimation:(UIStatusBarAnimation_)animation

Or at design time using the Info.plist property UIStatusBarHidden yes/no value.

slf
A: 

You could try creating a full-size view and adding it as a subview of your main window. Something like:

CGRect mainWindowSize = [UIScreen mainScreen].bounds;
UIView* overlay = [[UIView alloc] initWithFrame:mainWindowSize];
// Use colorWithRed:green:blue:alpha: or a solid color then manually tweak alpha
overlay.backgroundColor = [UIColor redColor];
overlay.alpha = 0.2; // transparency level
overlay.userInteractionEnabled = YES;
// Add it on top of the main window
UIWindow* mainWindow = (((MyAppDelegate*) 
          [UIApplication sharedApplication].delegate).window);
[mainWindow addSubview:overlay];

Caveats: You may have to manually hide the status bar. Also, this overlay view and its subviews are going to get all the user tap events. May want to make sure that's what you want.

Ramin