问题
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:
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.
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.
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.
I dont have the deltas because im using AL.
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?

(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)
回答1:
for iOS 7 and xcode 5 to avoid overlapping
use in
viewDidLoad method
self.edgesForExtendedLayout = UIRectEdgeNone;
self.automaticallyAdjustsScrollViewInsets = NO;
回答2:
Well, I have the same problem as you. I fixed it with many moves. I use ruby motion:
@window.bounds = CGRectMake(0, -20, UIScreen.mainScreen.bounds.size.width, UIScreen.mainScreen.bounds.size.height - 20)
@window.frame = CGRectMake(0, 0, UIScreen.mainScreen.bounds.size.width, UIScreen.mainScreen.bounds.size.height)
....
tabBarController.view.bounds = CGRectMake(0, 20, UIScreen.mainScreen.bounds.size.width, UIScreen.mainScreen.bounds.size.height - 20)
Let me know how it's going at your end.
update: attach the screenshot:

来源:https://stackoverflow.com/questions/18921062/how-to-apply-top-offset-for-status-bar-in-ios7-for-uitabbarcontroller-children-o