Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding view on StatusBar in iPhone

Is it possible to add a UIView on the staus bar of size (320 x 20)? I don't want to hide the status bar, I only want to add it on top of the status bar.

like image 825
Biranchi Avatar asked May 14 '10 11:05

Biranchi


People also ask

Where is my status bar on my iPhone?

The icons in the status bar at the top of the screen provide information about iPhone. On an iPhone with Face ID, there are additional status icons at the top of Control Center.

Where is customize status bar?

To customize it, first pull down the slider bar from the top of the screen. Next, tap on the three vertical dots in the top right corner. Now click on Status bar. You're in.

How can I make my Android status bar look like iPhone?

Just launch Xblast Tools and navigate to Status Bar -> Clock Settings -> Center clock. After a quick reboot, your status bar will be looking very similar to an iPhone's.


2 Answers

You can easily accomplish this by creating your own window above the existing status bar.

Just create a simple subclass of UIWindow with the following override of initWithFrame:

@interface ACStatusBarOverlayWindow : UIWindow { } @end  @implementation ACStatusBarOverlayWindow - (id)initWithFrame:(CGRect)frame {     if ((self = [super initWithFrame:frame])) {         // Place the window on the correct level and position         self.windowLevel = UIWindowLevelStatusBar+1.0f;         self.frame = [[UIApplication sharedApplication] statusBarFrame];          // Create an image view with an image to make it look like a status bar.         UIImageView *backgroundImageView = [[UIImageView alloc] initWithFrame:self.frame];         backgroundImageView.image = [UIImage imageNamed:@"statusBarBackground.png"];         [self addSubview:backgroundImageView];         [backgroundImageView release];          // TODO: Insert subviews (labels, imageViews, etc...)     }     return self; } @end 

You can now, for example in a view controller in your application, create an instance of your new class and make it visible.

overlayWindow = [[ACStatusBarOverlayWindow alloc] initWithFrame:CGRectZero]; overlayWindow.hidden = NO; 

Be aware of messing with the window key status by using - (void)makeKeyAndVisible or similar. If you make your main window (the UIWindow in your Application Delegate) loose key status, you will encounter problems with scrolling scrollviews to top when tapping the status bar etc.

like image 79
alleus Avatar answered Oct 10 '22 11:10

alleus


I wrote a static library mimicing Reeders status bar overlay, you can find it here: https://github.com/myell0w/MTStatusBarOverlay

MTStatusBarOverlayMTStatusBarOverlay

It currently supports iPhone and iPad, default and opaque black status bar styles, rotation, 3 different anymation modes, history-tracking and lots of more goodies!

Feel free to use it or send me a Pull Request to enhance it!

like image 30
myell0w Avatar answered Oct 10 '22 11:10

myell0w