iOS 7 status bar like iOS 6 iOS 7 status bar like iOS 6 objective-c objective-c

iOS 7 status bar like iOS 6


You can try writing this in your ViewWillappear or DidAppear. Here we are shifting the view frame 20 pixels down.

CGRect frame = self.view.frame;frame.origin.y = 20;if (self.view.frame.size.height == 1024 ||     self.view.frame.size.height == 768){    frame.size.height -= 20;}self.view.frame = frame;

This will work, but however this is not a very good idea. You can also change the text colour of the status bar to light or dark depending on your app background by calling the following method if it helps.

-(UIStatusBarStyle)preferredStatusBarStyle{     return UIStatusBarStyleLightContent; // For light status bar     return UIStatusBarStyleDefault // For Dark status bar}


If you are on Xcode 5 and you are installing in iOS 7 then sorry, this will not happen (as far as I know).

If you want to see the status bar on iOS 7 like iOS 6 than open your project in Xcode 4.x.x and install in iOS 7. One problem with this approach I found is that sometimes Xcode 4.x.x doesn't recognise an iOS 7 device.

But if your Xcode 4.x.x can show your iOS 7 device then it will work.

The .api generated from Xcode 4.x.x will work in both iOS 6 and iOS 7, but you will not get extra space (of the status bar) on iOS 7 and the new look of keyboard, picker, switch, etc. But yes, you will get the new UIAlertView (I don't know why this is new and the other controls are old.)

I hope we will soon get a better solution in Xcode 5 for this.

UPDATE:

I found the way to run the app from Xcode 5 as Xcode 4. This is just matter of the base SDK.If you want to built as Xcode 4 (iOS 6 SDK) from Xcode 5 then do the following.

  1. Close Xcode 4 and 5.

  2. In Xcode 4 Go to

    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs

  3. Here you will find iPhoneOS6.1.sdk. Copy this folder. And now go in Xcode 5 on the same path. In Xcode 5, you will find iPhoneOS7.0.sdk. Paste iPhoneOS6.1.sdk with it.

  4. Now close the Finder and launch Xcode 5. Go to project target setting -> Build Setting and find Base SDK. Select iOS 6.1 as Base SDK. This will also work for 6.0. You just need to find iPhoneOS6.0.sdk.

  5. Now you will see the device name twice in the run dropdown box. One for SDK 7.0 and one for SDK 6.1. So now you can run both ways with iOS 6 SDK and iOS 7 SDK.

I hope this will help someone.


I recently had to solve a similar problem, and I approached it in a slightly different way...

The approach was to use an extra view controller that acted as a container view controller for what was originally my rootViewController. First, i set up a container like this:

_containerView = [[UIView alloc] initWithFrame:[self containerFrame]];_containerView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;_containerView.clipsToBounds = YES;[self.view addSubview:_containerView];[self.view setBackgroundColor:[UIColor blackColor]];[UIApplication.sharedApplication setStatusBarStyle:UIStatusBarStyleLightContent animated:NO];

where the containerFrame was defined like this:

- (CGRect)containerFrame{    if ([MyUtilityClass isSevenOrHigher])    {        CGFloat statusBarHeight = [MyUtility statusBarHeight]; //20.0f        return CGRectMake(0, statusBarHeight, self.view.bounds.size.width, self.view.bounds.size.height - statusBarHeight);    }    return self.view.bounds;}

Finally, I added what was originally my rootViewController as a childViewController of the new one:

//Add the ChildViewControllerself.childController.view.frame = self.containerView.bounds;self.childController.view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;[self addChildViewController:self.childController];[self.containerView addSubview:self.childController.view];[self.childController didMoveToParentViewController:self];

Things to note: - Modal view controllers will still be presented in the iOS7 style, so I still have to account for that somehow.

Hope this helps someone!