iOS7隐藏状态栏但不调整顶部布局指南 [英] iOS7 hide status bar but not adjust top layout guide
问题描述
我处理Interface Builder中的自动布局设置。当我在运行时隐藏状态栏时,我想不会偏移固定到顶部布局指南的视图。
I deal with autolayout set up in Interface Builder. I want to not offset views that are pinned to top layout guide when I hide status bar in runtime.
我发现 myViewController.topLayoutGuide。隐藏状态栏时,长度
从20更改为0。怎么预防呢?或者(作为解决方法)如何设置各种窗口大小的全屏视图,而无需针对顶部布局指南?
I have discovered that myViewController.topLayoutGuide.length
changes from 20 to 0 when hiding status bar. How to prevent it? Or (as workaround) how to set up fullscreen view for various window sizes without pin to top layout guide?
描述我的情况的一些代码:
Some code to describe my situation:
Log(@"frame: %@, top: %.0f", NSStringFromCGRect(myViewController.myView.frame), self.topLayoutGuide.length);
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
Log(@"frame: %@, top: %.0f", NSStringFromCGRect(myViewController.myView.frame), self.topLayoutGuide.length);
输出:
frame: {{40, 24}, {240, 40}}, top: 20
frame: {{40, 4}, {240, 40}}, top: 0
推荐答案
topLayoutGuide属性是readonly,你不能阻止它改变。
The topLayoutGuide property is readonly and you can't prevent it from changing.
你可以将你的物品固定在topLayoutGuide上,而不是超级视图。这应该可以解决您的问题。
You can pin your items not to the topLayoutGuide but to the superview. That should resolve your problem.
这篇关于iOS7隐藏状态栏但不调整顶部布局指南的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!