4

I'm working on an iOS 6 app that's needs to be compatible with iOS 7. I use UIAppearance to style the tint color on some of the components of the app, in particular the UINavigationBar and its Bar Button items.

The problem is that when I deploy the app on an iOS 7 device, the bar button items' tint color is modified to the color of the navigation bar. I understand that iOS 7’s UIAppearance introduces some modifications in this (UINavigationBar) and that if I want to use it properly for iOS 7 I should set the barTintColor property instead, however since I mean to keep my app as iOS 6 and I’m compiling it with SDK 6 in Xcode 4.6.3 there’s no way I can use that property.

I’ve tried many things, some of them worked in some scenarios but I still can’t get it to work in the whole app. Any ideas?

Here's a screenshot of the problem I'm having

enter image description here

EDIT 1

To style the app I added the following code in the AppDelegate

[[UINavigationBar appearance] setTintColor:[UIColor colorWithRed:245.0/255.0 green:245.0/255.0 blue:245.0/255.0 alpha:1.0]];
[[UIBarButtonItem appearance] setTintColor:[UIColor colorWithRed:230.0/255.0 green:0.0/255.0 blue:0.0/255.0 alpha:1.0]];

EDIT 2

I tried to deploy the app from Xcode 5 with SDK 7 and deployment target 5, but when I deployed it on an iOS 7 device it changed my UI to iOS 7. This is not a matter of recognising when is the app is running in iOS 7 because I don't want the app to look iOS 7 like, I want it to look the same as it looks in iOS 6

Thanks in advance!

Hussain Shabbir
  • 14,801
  • 5
  • 40
  • 56
mikywan
  • 1,495
  • 1
  • 19
  • 38
  • what code do you use? – Ilario Oct 29 '13 at 12:36
  • You don't want your app to look like an iOS 6 app on iOS 7. Your app will look old and badly-written; your users will hate using your app and will leave you bad reviews. Much better to put the work into getting the UI right on both versions. – Simon Oct 29 '13 at 13:56
  • Thanks Simon! I am aware of that, however my situation right now requires that I have it working as an iOS 6 app – mikywan Oct 29 '13 at 14:09
  • 1
    @laucel Apparently this is bug. The solutions are: 1) Set the UIBarButtonItem's tintColor directly, but at a later time after viewDidLoad. (I use viewDidAppear). 2) Start linking your app with iOS 7.0 SDK and Xcode 5.0.x. It will come a time in the future when linking with iOS 7 will be a requirement for the App Store. – mikywan Nov 29 '13 at 15:24
  • thanks @mikywan, I'll try solution 1) and 2) later in the future – laucel Nov 29 '13 at 16:43

3 Answers3

2

You don't need to restrict yourself to the iOS 6 SDK in order for your app to run on iOS 6. The minimum version that your app will run on is set using the 'Deployment Target' under Deployment Info in the General tab. If you set that to iOS 6, but set your 'Base SDK' to Latest iOS under the Build Settings tab, you'll be able to write an app that can run on either.

Once you've done that, you need to check at runtime whether the features you need are available. So you might do something like this:

UIColor *navigationBarColor = [UIColor redColor];
if ([self.navigationBar respondsToSelector:@selector(setBarTintColor:)])
{
    self.navigationBar.barTintColor = navigationBarColor;
}
else
{
    self.navigationBar.tintColor = navigationBarColor;
}
Simon
  • 25,468
  • 44
  • 152
  • 266
  • Thanks Simon. I opened my project in Xcode 5 with SDK 7 and deployment target 5, but when I deployed it on an iOS 7 device it changed my UI to iOS 7 – mikywan Oct 29 '13 at 12:49
  • 1
    Yes, it will do. You don't want your app to look like an iOS 6 app on iOS 7; your users will hate it. – Simon Oct 29 '13 at 13:55
0

You can determine, at runtime, whether you're running iOS 6 or 7, and introduce OS-specific user interface tweaks at that time.

Best way to check for iOS 7 or earlier

Specifically, to check for iOS 7 or higher:

#define IS_OS_7_OR_LATER    ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)

Then you can just check:

if (IS_OS_7_OR_LATER) {
    // iOS 7 tweaks
} else {
    // iOS 6 tweaks
}
Community
  • 1
  • 1
Craig Otis
  • 31,257
  • 32
  • 136
  • 234
  • 1
    I understand Craig but in order to work with iOS 7 new features I need to compile the app with SDK 7 and when I do that the app looks like iOS 7 – mikywan Oct 29 '13 at 12:58
  • Right - your app should look like iOS 7 on a device running iOS 7. When you compile it with SDK 7.0, it will still run on a device running iOS 6, and will look like iOS 6 on that device. – Craig Otis Oct 29 '13 at 14:04
  • 2
    @mikywan - did you find a solution for this issue? I have the same issue, linking with SDK 7 is not an option at this moment. – Moshe Gottlieb Nov 04 '13 at 10:47
  • 1
    @iMoses No I have not, I reported the bug to Apple a week ago, I'm waiting for their answer. – mikywan Nov 04 '13 at 17:15
0
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) 
{


}
Jitendra
  • 5,055
  • 2
  • 22
  • 42
shalunv
  • 54
  • 3