Is it possible for content in a view to overlap the status bar in iOS? I don't want to cover the whole status bar - just have a graphic extend a few pixels into it.
Are there any examples of this in the store now? Or does the HIG prohibit it?
I've seen examples of apps that place their own content in the iOS status bar. Reeder is perhaps the most popular example of this. But in Reeder, the content is contained entirely within the status bar.
You can use UIWindow,
UIApplication *app = [UIApplication sharedApplication];
UIWindow *overlapView = [UIWindow new];
overlapView.windowLevel = UIWindowLevelStatusBar + 1;
overlapView.frame = app.statusBarFrame; // you can set any size of frame you want
P.S. instance of UIWindow is set hidden = YES by default, so you should set hidden = NO when you want to display the overlapView;
Related
I have a situation where I'm adding my store view as a subview of the top window.
this is done by the following code:
NSArray* windows = [[UIApplication sharedApplication] windows];
int count = [windows count];
UIWindow* topWindow = [windows objectAtIndex:count - 1];
[topWindow addSubview:_storeView];
When I'm purchasing a product, in some cases (not sure exactly when and why) the in app purchase alerts, where the user needs to enter his app id credentials and approve the transaction are covered by my view and are not visible to the user.
Only when i dismiss my view i can see them and completing the purchase flow.
How can i make sure that those alerts will appear on top of all other views. and why is it not consistently, on some cases it is visible to the user and on some cases it isn't…
Appreciate any help.
found a solution.
instead of using current window I'm creating a new window which is floating above other UI elements (like the system keyboard).
I'm setting its window level property to UIWindowLevelStatusBar for displaying above status bar but underneath uialertviews
Why you are adding your view directly to the window ? i advise you to read the Apple documentation UIViewController programming guide.
The problem can be this lines of code :
NSArray* windows = [[UIApplication sharedApplication] windows];
int count = [windows count];
UIWindow* topWindow = [windows objectAtIndex:count - 1];
[topWindow addSubview:_storeView];
What is the root controller of your application ? are you using a container controller ( UINavigationController, UITabBarController,...). can you please show your AppDelegate code ?
This code in the appDelegate makes my app behave strange
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window.windowLevel = UIWindowLevelStatusBar + 1;
return YES;
}
When hiding the keyboard from the function [myTextView resignFirstResponder] I'm getting my keyboard disappearing under the view, not sliding down as it should.
What is the best way to change this? Why does UIWindowLevelStatusBar + 1 mess up all the app structure?
EDIT:
What I'm trying to do is create a view on top of the statusBar. Is setting UIWindowLevelStatusBar + 1 in the appDelegate a wrong way to do this?
Man, i know this is 2 year old but here it goes:
Works on iOS 7 and 8, not tested on 9 betas.
I'm adding a ticker to the status bar. Yeah i know apple does not like it, but users have the choice to use it there ore somewhere else.
In app Delegate, when you want to hide the contents of the status bar (carrier, hour, battery), you call:
self.window.windowLevel = UIWindowLevelStatusBar+1;
Ok
The problem was to figure out how to get the contents back, right ? That was my problem too. Here it is:
self.window.windowLevel = UIWindowLevelStatusBar-1;
Bye
The keyboard also exists in a window (everything on the screen does) and that window has a level lower than your window's.
Why are you setting your window level so high? If you tell us what you're trying to accomplish, we may be able to suggest an alternate approach.
Hide the status bar and set frame for navigation bar simple.
CGRect statusFrame = [UIApplication sharedApplication].statusBarFrame;
[[UIApplication sharedApplication] setStatusBarHidden:YES];
self.navigationController.navigationBar.frame = CGRectMake(0, statusFrame.size.height, 320,46);
[[AppDelegate instance].window addSubview:statusView];
How can i add notification icon on a button..I m able to add it on application icon but not on the button...Help me pls...
UIApplication *application = [UIApplication sharedApplication];
application.applicationIconBadgeNumber = 1; // set to any integer
I m using this code..
Thank you....
You can use some custom views. Here is the nice one: link
While some classes may have private APIs to add such icons, I believe the only class that publicly supports it is UITabBarItem.
Your best bet would be to create your own custom view class that draws the icon appropriately, and then layer it on top of your button (e.g. by adding it as a subview of the button at the proper position).
Is there a built in badge icon like the info icon so that I can show status updates on other views in my app? It's easy enough to duplicate manually but I'd like to use a built in resource if it's available.
Check out CustomBadge, the site is in German, but theres sample source code there.
You can also steal a badge from a tabbar view like this:
.h
IBOutlet UITabBarItem *tabbarItem;
UIView *badgeView;
.m
badgeView = [[UIView alloc] initWithFrame:CGRectMake(25,100, 32, 32)];
badgeView.backgroundColor = [UIColor clearColor];
badgeView.clipsToBounds = NO;
[badgeView addSubview:[((UIView *)[tabbar.subviews objectAtIndex:0]).subviews objectAtIndex:0]];
and to set the value for that badge:
tabbarItem.badgeValue = unreadCount;
Note that you don't have to use a UITabbar thats visible in your app, you are simple stealing the badge resource.
I'm sure it's not available for developers since Apple doesn't like to reuse assets for different purposes. Those badges have one definitive and simple purpose -- show the number of updates on the app icon. That's the only purpose they serve.
I know, it's a strange question ^^,
I would like to know if there is a way to write some text in (or on) the UIStatusBar. In particular I want to write some text on the Status Bar when the user press a UIButton.
Thanks!
I'm not sure if you can draw directly into the status bar, but you should be able to draw on top of it in a custom view. You can get the status bar's frame using:
CGRect statusBarFrame = [[UIApplication sharedApplication] statusBarFrame];
And you can get the application's main window (presumably the status bar's superview) using:
UIWindow *mainWindow = [[UIApplication sharedApplication] keyWindow];
You should be able to add your custom view directly to the key window in the status bar's frame. For an example of an app that appears to "modify" the status bar, take a look at Reeder.
No, the status bar is a system-controlled element. It's content cannot be modified by a third-party application.
Check out this work in progress: https://github.com/maciekish/APStatusBarExtensions
MTStatusBarOverlay is what you want :
https://github.com/myell0w/MTStatusBarOverlay
Definitely the easier to use !