简体   繁体   English

iOS 6和7状态栏设计

[英]iOS 6 & 7 status bar design

I am currently working on an iOS 6 app. 我目前正在使用iOS 6应用。 Running this application on iPhone 4/5 runs well. 在iPhone 4/5上运行此应用程序运行良好。 The only problem is that with the new iOS 7 coming out, the design are ruined. 唯一的问题是,随着新的iOS 7的发布,设计被毁了。 Status bar are now part of the app, and all the view in my application get push to the top, overlap with the status bar. 状态栏现在是应用程序的一部分,应用程序中的所有视图都被推到顶部,与状态栏重叠。

What is the best solution to resolve this issue? 解决此问题的最佳解决方案是什么? I am using UINavigationController and some custom view. 我正在使用UINavigationController和一些自定义视图。 Done some reading, some suggest that I include a custom container view to create something like iOS 6 'status bar', since the view at the top will be black and empty. 做完一些阅读后,有人建议我包括一个自定义容器视图,以创建类似iOS 6的“状态栏”,因为顶部的视图将为黑色且为空。 Is there any other solution to this? 还有其他解决方案吗? Or maybe the right way to fix my apps to support both iOS 6 & 7 design? 还是修复我的应用程序以支持iOS 6和7设计的正确方法?

There is a simplest solution for this. 有一个最简单的解决方案。 We have to Thank apple for this concept. 我们必须感谢苹果的这个概念。

Checkout the solution below 查看以下解决方案

  1. First of all in storyboard/xib change screen size to 4" from Utility Inspector window 4th tab 首先,在Storyboard / xib中,将屏幕尺寸从Utility Inspector窗口的第4个选项卡更改为4英寸
  2. Arrange your uicontrols according to the design (ie start framing below the statusbar) 根据设计安排您的uicontrols(即在状态栏下方开始构建框架)
  3. Now go to 5th tab into Utility Inspector window 现在转到“实用程序检查器”窗口的第5个选项卡
  4. You must have frame for your each control 每个控件都必须有框架
  5. Turn your eyes below the frame and you can see the iOS6/7 Deltas 将视线移到框架下方,即可看到iOS6 / 7 Delta
  6. In the DeltaY field reduce 20 pixels for each control. 在DeltaY字段中,每个控件减少20个像素。 I mean fill up -20 in Delta Y field 我的意思是在Delta Y字段中填满-20
  7. So now run your project with both iOS7 & 6 you will have what you want. 因此,现在同时使用iOS7和6运行您的项目,您将拥有所需的内容。

Note: You have to have uncheck the "Use Autolayout" in order to use delta 注意:您必须取消选中“使用自动版式”以使用增量

Enjoy Programming!! 享受编程!

Y位置的结帐Delta值

One solution that will allow you to: 一种解决方案将使您能够:

  • Support both iOS6 and iOS7 as a deployment target. 同时支持iOS6和iOS7作为部署目标。
  • Preserve your existing iOS6-style code, and defer the impact of a redesign 保留您现有的iOS6样式的代码,并推迟重新设计的影响

. . . is to add the following to your view controller: 将以下内容添加到您的视图控制器:

#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7"))
{
    self.edgesForExtendedLayout = UIRectEdgeNone;
}

. . since, I'm using code-based views, I add it in loadView, however it would also work in viewDidLoad 因为我使用的是基于代码的视图,所以将其添加到loadView中,但是它也可以在viewDidLoad中使用

Try this in your AppDelegate.m in didFinishLaunching 在didFinishLaunching的AppDelegate.m中尝试此操作

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {

       [application setStatusBarStyle:UIStatusBarStyleLightContent];

       self.window.clipsToBounds =YES;

       self.window.frame =  CGRectMake(0,20,self.window.frame.size.width,self.window.frame.size.height-20);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM