iOS 7状态栏半透明,具有向后兼容性 [英] iOS 7 status bar translucency with backwards compatibility
问题描述
我构建了我的应用程序,在iOS 6中有一个半透明的导航栏。我想利用iOS 7中的半透明状态栏并保持iOS 6中的应用程序,但我的内容总是在iOS的状态栏下面7,底部缺少20px。我认为我可以进行非常繁琐的代码更改,检查设备是否具有iOS 7,然后相应地调整我的内容,但我担心这将是很多工作。
理想情况下,我想在每个视图控制器视图的顶部添加20px的填充,以便内容向下移动,并且在iOS 6上使用不透明的导航栏仍能正常运行。
我已经阅读了主题中存在的主题
I built my app to have a translucent navbar in iOS 6. I'd like to utilize the translucent status bar in iOS 7 and keep the app as is in iOS 6, but my content is always underneath the status bar in iOS 7, with 20px missing on the bottom. I figure that I can make the very tedious code changes that check whether the device has iOS 7 and then adjust my content accordingly, but I fear that this is going to be a lot of work.
Ideally, I'd like to add 20px of padding to the top of every view controller's view, so that the content shifts down, and still functions fine with an opaque navbar on iOS 6.
I've read the threads that exist on the subject 1 2, but none of the answers provided solved my problem.
I should note that I am NOT using Interface Builder and all my VCs are being created programmatically.
If you are using auto layout
, then all you need to do is add a Vertical Constraint
from your top most view to Top Layout Guide
as shown below and it should take care the top spacing.
For more info: https://developer.apple.com/library/ios/qa/qa1797/_index.html
这篇关于iOS 7状态栏半透明,具有向后兼容性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!