I'm in the process of upgrading my app to iOS7. However I want to preserve the iOS6 interface as well. It works well except for the navigation bar(s). In iOS7 they look great (just the default color with the translucent property to YES. In iOS6 the navigation bars are showing as the default blue bars and I want them to be black translucent.
What I do is check the version of the iOS and then perform some code. In the debugger I see they right version in the vComp variable but the color is not changing. Don't mind the redColor property, that's just for the test. In both ways I am presented with the default color.
Here is my code:
- (void) fixNavBarColor:(UINavigationBar*)bar {
NSArray *vComp = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."];
if ([[vComp objectAtIndex:0] intValue] >= 7) {
bar.barTintColor = [UIColor redColor];
bar.translucent = NO;
}
else {
bar.tintColor = [UIColor redColor];
bar.opaque = YES;
}
}
There is no error or warning. Any ideas?
NSArray *vComp = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."];
and replace the[[vComp objectAtIndex:0] intValue] >= 7
with just[[[UIDevice currentDevice] systemVersion] >= 7
this[[[UIDevice currentDevice] systemVersion] intValue]
will return the value as6
or7
or etc no need to do a pointlesscomponentsSeparatedByString:
call – Popeye