iOS 7 navbar colours not showing properly on iPhone 4 - iphone

My navigation bar colours appear normally in iOS 7
Deploying iOS 6.0, but if the system version is iOS 7.0 or later, some of the navigation bar colouring doesn't display properly on iPhone 4. Works fine in iPhone 5.
Here's how I am doing it:
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(#"7.0")) {
self.edgesForExtendedLayout = UIRectEdgeNone;
[self.navigationController.navigationBar setBarTintColor:[UIColor blueColor]];
[self.navigationController.navigationBar setTranslucent:YES];
}
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
Maybe the last line is the problem (setTranslucent) since I have heard that iPhone 4 has some problems with the translucency, but I'm pretty sure that you could set the navbar to be translucent in iOS 6 as well. Will try getting rid of that out next and update if it fixes anything.
EDIT:
Looks like the bar colour disappears after I dismiss a presented view controller. But it doesn't screw up on anything but the iPhone 4.

Get rid of [self.navigationController.navigationBar setTranslucent:YES]; and it should work fine.
If you want, you can check the device model
(see here: Determine device (iPhone, iPod Touch) with iPhone SDK)
and adjust view accordingly.

Related

iOS7 Status Bar issue

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

uiview appears distorted in ios7 but works fine for ios6 and others

UIView of my app appears fine in ios6 but when it comes to ios7 the entire view is distorted. In ios7 the whole view is lifted upwards.
EDIT :
Then I applied this code:
float SystemVersion=[[[UIDevice currentDevice] systemVersion] floatValue];
if(SystemVersion<7.0f)
{
//Currently your app is running in IOS6 or older version. So you need not to do anything.
}
else
{
// Currently your app is running in IOS7. Do the following.
CGRect TempRect;
for(UIView *sub in [[self view] subviews])
{
TempRect=[sub frame];
TempRect.origin.y+=20.0f; //Height of status bar
[sub setFrame:TempRect];
}
}
but still there is no change. How do I resolve this?
Try this way..
IOS & DISPLAY
OR
This..
Status Bar Issue
This way make the your All subviews as +20 pixels i.e.Increase the +20 of y-axis for all views
Set the deleta for the ios 7. so, it will display the good in both ios 6 & 7.
//Give it frame if navigation bar and status bar both displaying on screen
// first check if device have ios 7
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(#"7.0"))
{
self.view.frame=CGRectMake(0,64,320,self.view.height);
}
try my answer...write that code in ViewdidLoad method..
Status Bar issue
Happy Coding!!!
Please see below note
Using xcode 5,
click on xib,Go to file inspector and change setting as below
Deployment target as ios 7
here,You need to crate two xib view based on view as ios 7 and later and view as ios 6 and earlier and white condition based on xib call
Define below code in .m file
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
if view as IOS 7.0 and later
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(#"7.0"))
//Here call ios 7 xib
}else{
//Here call ios 6 and earlier xib
}
You have to create two xib for ios6 and ios7.
than You have to check condition if device is of ios7 than call ios7 xib otherwise go for ios6.

iOS 7 Default image overlapped by status bar in multi-tasking view

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

View got hidden below UINavigationBar 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

if the device is ios 5

How can I determine if the device that is running my app is ios 5?
I'm trying to use the UIAppearance class but it will give an error if it's running on ios versions other than 5. so I want to have if statement that only runs this line of code if the device is ios5.
Thanks,
EDIT:
SO here is the solution,
float version = [[[UIDevice currentDevice] systemVersion] floatValue];
if (version >= 5.0){
[[UINavigationBar appearance] setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
}
You can get the OS version using
[[UIDevice currentDevice] systemVersion]
But a better way would be to check for specific features, Something along the lines of
if(NSProtocolFromString(#"UIAppearance")) {
// Do something
}
To see if that class is available, then perform you operations.
Failing that it is also possible to make sure you only build for iOS 5, and it will only install on iOS 5 devices.