如何在iOS7中为UITabBarController子项应用状态栏的顶部偏移量 [英] How to apply top offset for status bar in iOS7 for UITabBarController children only

查看:121
本文介绍了如何在iOS7中为UITabBarController子项应用状态栏的顶部偏移量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序是一个基于UITabBarController的应用程序,有3个孩子vc。状态栏与我的viewcontrollers重叠。我已经尝试了在SO中找到的所有内容:

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. 我尝试将此添加到我的AppDelegate:

  1. I tried adding this to my AppDelegate:

//向下偏移以为状态栏腾出空间
self.window.bounds = CGRectMake(0,-20,self.window.frame.size.width,self.window.frame .size.height);

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

它起作用了,因为它将整个UITabBarController向下移动了20但是这导致了标签在底部被-20切断。

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.

所以我想我只想将效果应用到每个标签中的UIViewControllers,因为没有太多要切断的在底部。

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. 所以我尝试将相似的代码添加到viewDidLoad并随后调用setNeedsDisplay:

  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);

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. 我尝试添加这个to viewDidLoad

  1. I tried adding this to viewDidLoad

self.edgesForExtendedLayout = UIRectEdgeNone;

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;
 }

但没有雪茄。


  1. 我没有增量,因为我正在使用AL。

  1. 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.

我想在每个需要它的viewcontroller中将视图向下移动是最好的选择,但为什么我的代码不能用于#2?

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)

推荐答案

适用于iOS 7和xcode 5以避免重叠

for iOS 7 and xcode 5 to avoid overlapping

使用

viewDidLoad方法

viewDidLoad method

self.edgesForExtendedLayout = UIRectEdgeNone;
self.automaticallyAdjustsScrollViewInsets = NO;

这篇关于如何在iOS7中为UITabBarController子项应用状态栏的顶部偏移量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆