Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to apply top offset for status bar in iOS7 for UITabBarController children only

Tags:

ios7

statusbar

My app is a UITabBarController based app with 3 children vc. The status bar is overlapping with my viewcontrollers. I have tried everything I have found in SO:

  1. I tried adding this to my AppDelegate:

    //Offset downwards to make room for status bar self.window.bounds = CGRectMake(0, -20, self.window.frame.size.width, self.window.frame.size.height);

It worked because it moved the entire UITabBarController down by 20. But this resulted in the tabs being cut off at the bottom by -20.

So Im thinking i just want to apply the effect to the UIViewControllers in each tab since there is not much to cut off at the bottom.

  1. So I tried adding similar code to the viewDidLoad and calling setNeedsDisplay afterwards:

    self.view.bounds = CGRectMake(0, -20, self.view.frame.size.width, self.view.frame.size.height);

But this has no effect at all, still get overlapping.

  1. I tried adding this to viewDidLoad

    self.edgesForExtendedLayout = UIRectEdgeNone;

and I also unchecked the Extend Edges Under Top Bars but it still runs into the status bar. Also tried:

if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
 {
    self.edgesForExtendedLayout = UIRectEdgeNone;
 }

but no cigar.

  1. I dont have the deltas because im using AL.

  2. I dont want to HIDE my status bar because it displays open/close times so the user would find it handy to be able to see the time.

Im thinking shifting the view down a bit in each viewcontroller that needs it is the best option, but why didnt my code work for #2?

Hierarchy

(btw:not sure why code format isnt working and the numbering is off, even when i try to edit it, it seems to be working fine in the edit view but not in the pre-view or live-view)

like image 493
marciokoko Avatar asked Sep 20 '13 16:09

marciokoko


1 Answers

for iOS 7 and xcode 5 to avoid overlapping

use in

viewDidLoad method

self.edgesForExtendedLayout = UIRectEdgeNone;
self.automaticallyAdjustsScrollViewInsets = NO;
like image 105
Anilkumar iOS - ReactNative Avatar answered Oct 14 '22 11:10

Anilkumar iOS - ReactNative