I have found many links for Status Bar issue in iOS 7 bt none of them helped much.
The issue is my application runs well in iOS6 but when I try to run it on iOS7, I want the iOS7 look and feel.
The status bar gels nicely with a UIViewController like below :
But for UINavigationController it goes black like below :
I managed to change the text-color of the statusBar using the following code in AppDelegate :
if ([[UIView appearance] respondsToSelector:#selector(setTintColor:)]) {
[[UIView appearance] setTintColor:[UIColor whiteColor]];
}
Also, my plist file has the following entry :
View controller-based status bar appearance set to NO
and my AppDelegate has :
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
I want the statusBar to take the Blue color when a NavigationController is loaded.
NOTE : I have used the following code for iOS7 support :
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000
self.edgesForExtendedLayout=UIRectEdgeNone;
#endif
Don't know if this caused the issue.
It's hard to find the solution to your problem, but try using this guide, is really good:
http://www.appcoda.com/customize-navigation-status-bar-ios-7/
It works fine if you use different images. One for iOS7 (20px higher) and one for the others and set this image as background for your navBar.
Hope this help :)
There's a good and explained answer here.
Status bar and navigation bar issue in IOS7
and here
iOS 7 - Status bar overlaps the view
Related
I'm currently developing an app for iOS7, using XCode5.
Today was my first attempt to test the app on a real device (iPhone 4 with iOS7.0).
I've noticed there is a difference between what I see in the simulator and what I see on the real device.
The Navigation Bar and Tab Bar are defined as follows:
[self.navigationController.navigationBar setBarStyle:UIBarStyleBlack];
[self.navigationController.navigationBar setTranslucent:YES];
[self.tabBarController.tabBar setBarStyle:UIBarStyleBlack];
[self.tabBarController.tabBar setTranslucent:YES];
The level of transparency is very different between the simulator and the real device, as can be seen in the screenshots below:
1.Screenshot from Simulator:
2.Screenshot from a real iPhone:
I can't find anything about that online. Am I doing something wrong?
Thank you.
sorry for poor english .. I'm using google translator.
I was having this same problem, but in colors of the buttons in the tabbar and navigationBar. I found that this is a configuration of iOS. On your device go to Settings> General> Accessibility> Increase Contrast.
It remains now to discover how to predict whether the user is modified with these settings and make adjustments via code.
Can't hide status bar on view controller on ios 7 device.
Already tried setting through plist file and also in Appcontroller.mm but still i doesn't hide the status bar
[[UIApplication sharedApplication] setStatusBarHidden:YES];//Doesn't help
Go to info.plist and add two attributes if not present. set "Status bar is initially hidden" to YES and set UIViewControllerBasedStatusBarAppearance to NO. This will hide status bar for your app.
That's because iOS 7 has changed the way it deals with the status bar.
Setting UIViewControllerBasedStatusBarAppearance to NO on your app Info.plist should work.
I had the same issue recently. Be sure that you are targeting the correct view controller. Try to hide the status bar in the root view controller. Also, I´m implementing the method (BOOL)prefersStatusBarHidden (doc) in my UIViewControllers to hide the status bar. By using this method, you can forward the preferred configuration to a "child view controller". Also, this method works fine in UIViewControllers presented as modal.
// for ios 7
- (BOOL)prefersStatusBarHidden
{
return YES;
}
// for ios 6
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[[UIApplication sharedApplication] setStatusBarHidden:YES];
}
For iPad (iOS 7.0) need to put another value at Info.plist file.
UIStatusBarHidden boolean value YES.
My app is compiled against iOS 6 SDK (haven't gotten the time to upgrade to iOS 7 SDK). So I just noticed that the Default image is overlapped by the status bar. This seems to happen only in the "multi-tasking" view but not when resuming my app from background for some reason.
See this image:
I don't think many people will notice this at all.
However, as far as I know you could possibly disable the Statusbar when the app gets in backround.
To do this just use this method in the delegate:
- (void)applicationWillResignActive:(UIApplication *)application {
//code to disable statusbar
}
In the applicationDidBecomeActive method you could enable the statusbar again.
- (void)applicationDidBecomeActive:(UIApplication *)application {
//code to enable the statusbar
}
Furthermore you can take a look at this previous asked question: Status bar won't disappear
If you got any questions feel free to ask!
edgesForExtendedLayout does the trick for iOS 7. However, if you build the app across iOS 7 SDK and deploy it in iOS 6, the navigation bar appears translucent and the views go beneath it. So, to fix it for both iOS 7 as well as for iOS 6 do this:
self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
if ([self respondsToSelector:#selector(edgesForExtendedLayout)])
self.edgesForExtendedLayout = UIRectEdgeNone; // iOS 7
Earlier, I was using iOS 6.1 for my project. Recently I have switched to iOS 7. For, a lot of changes I knew, I updated my code.. But I have observed a strange behavior. My view on every screen gets hidden below navigation bar. Repositioning view solves the problem for iOS7, but creates problems for older iOS versions.
Can anyone explain me, what is the reason and why does it happen?? What has been changed in iOS 7 that's causing this problem??
Any help would be appreciated..
Try navigationBar.translucent = NO;, It is YES by default in iOS7.
It is also good to take a look on this part of UINavigationBar documentation:
New behavior on iOS 7. Default is YES. You may force an opaque
background by setting the property to NO. If the navigation bar has a
custom background image, the default is inferred from the alpha values
of the image—YES if it has any pixel with alpha < 1.0 If you send
setTranslucent:YES to a bar with an opaque custom background image it
will apply a system opacity less than 1.0 to the image. If you send
setTranslucent:NO to a bar with a translucent custom background image
it will provide an opaque background for the image using the bar's
barTintColor if defined, or black for UIBarStyleBlack or white for
UIBarStyleDefault if barTintColor is nil.
Edit:
Setting 'navigationBar.translucent' value causes exception if you run project in devices/simulators having older iOS versions.
So you can add a version check like this:
float systemVersion = [[[UIDevice currentDevice] systemVersion] floatValue];
if (systemVersion >= 7.0)
{
navigationBar.translucent = NO;
}
Another option would be to set:
vc.edgesForExtendedLayout = UIRectEdgeNone;
Swift 3:
vc.edgesForExtendedLayout = []
You can stop your views going under the navigation bar, in your viewController:
self.edgesForExtendedLayout = UIRectEdgeNone;
Swift 3+:
self.edgesForExtendedLayout = []
If you do not need translucent navigation bar in your app you can fix this on iOS7 and iOS6 without code changes.
In storyboard select your navigation controller and then open "Attributes Inspector". Then under "Simulated Metrics" set "Top Bar" to some value but not to "translucent":
Now your views on iOS6 and iOS7 will have the same positioning as before.
Point #7 on this list does the trick. You still have to wrap it in iOS 7-checking code like #null's answer:
float systemVersion = [[[UIDevice currentDevice] systemVersion] floatValue];
if (systemVersion >= 7.0) {
viewController.edgesForExtendedLayout = UIRectEdgeNone;
}
The whole article is useful to those transitioning to iOS 7.
Use this property for your VC, in-order to avoid overlap of ur statusbar with your VC Swift :
self.edgesForExtendedLayout = []
Objective C
self.edgesForExtendedLayout = UIRectEdgeNone;
Look up this key: UIViewControllerBasedStatusBarAppearance.
It's used in your app's info PLIST file and will come up as:
View controller-based status bar appearance
This will allow you to control the status bar's appearance. There's a bunch of API changes for status bars, go have a look in the documentation for new UIViewController methods such as
- (void)prefersStatusBarHidden;
For me the best way for transparent Navigation Bar is to change the shadowImage and backgroundImage of the bar.
navigationController?.navigationBar.isTranslucent = true
navigationController?.navigationBar.backgroundColor = nil
navigationController?.navigationBar.setBackgroundImage(UIImage(named: "navBarBackground")?.resizableImage(withCapInsets: .zero, resizingMode: .stretch), for: .default)
navigationController?.navigationBar.shadowImage = UIImage()
In Swift 2.2, use
self.edgesForExtendedLayout = .None
just switched to iOS 4 on my iPhone 3GS and some of my apps broke.
One issue I had is that I had a UIToolbar with some buttons, tinted to pink, that worked well on the 3.1.3 OS. After upgrading to iOS 4, the toolbar was still tinted, but the buttons it contained were no longer affected by the tint. The toolbar was pink while the buttons were regular-blue.
Looked around for it on the net, but found no reference of such a thing.
Anyone knows what broke in the process?
(must be frank here - I knew the answer before posting, just didn't know how to load this data to StackOverflow. Thought the solution I found was valuable for others, so wanted to post it here. I'm new here, so please no harsh critics :) )
So eventually the problem resulted from, AFAICT, a change in behavior in the OS.
As stated the tint code worked before the upgrade and was written like this:
// Toolbar content
NSArray *items=[NSArray arrayWithObjects: ... ]; // PSEUDO CODE HERE
[toolbar setItems:items];
// Add tint
toolbar.tintColor = [UIColor colorWithRed:0.83 green:0.43 blue:0.57 alpha:0.5];
What I needed to do, was just reverse the order of things:
// Add tint
toolbar.tintColor = [UIColor colorWithRed:0.83 green:0.43 blue:0.57 alpha:0.5];
// Toolbar content
NSArray *items=[NSArray arrayWithObjects: ... ]; // PSEUDO CODE HERE
[toolbar setItems:items];
(If you created UIToolbar in Interface Builder, you can change it's tint there, and that applies for the buttons as well).
I guess the tint updated all buttons before iOS 4, while in iOS 4 it doesn't and when adding buttons, they check for existing tint. But this is just a guess. The solution works anyhow..
Hope this helps someone, and that I didn't violate any sacred SO rules...
Cheers!
Well, it seems more like an OS bug than a feature, since navigation bars do change their item's color when you set their tintColor.
We've found that if you change the item's style, it refreshes their color as a side effect. Doing the following worked in our case. The original buttons are bordered, so we change them to plain and set them to bordered again. You may do a more complicated and generic code that saves the current style, sets another one and then switchs back. I am just to lazy to do that. :D Anyway, you get the idea.
toolbar.tintColor = //<some dynamically obtained UIColor>
// Workaround to properly set the UIBarButtonItem's tint color in iOS 4
for (UIBarButtonItem * item in toolbar.items)
{
item.style = UIBarButtonItemStylePlain;
item.style = UIBarButtonItemStyleBordered;
}
Regards,
Rula.