iOS 7中的导航栏和状态栏问题 [英] Navigation bar and Status bar issue in iOS 7
问题描述
我在 iOS7之前使用
,现在我需要在我的应用上添加 XIB
创建了一个没有状态栏
的应用程序状态栏
并且状态栏背景颜色
应该与导航栏
背景颜色。所以我试过(在我的 info.plist
):
I have created an application using XIB
without Status Bar
before for iOS7
, now i need to add Status bar
on my app and Status bar background color
should same as Navigation bar
background color. So i have tried like (In my info.plist
) :
1) Set View controller-based status bar appearance to NO
2) Set Status bar style to UIStatusBarStyleLightContent
这是我的代码 App Delegate
:
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
[[UINavigationBar appearance] setBarStyle:UIBarStyleDefault];
[[UINavigationBar appearance] setBackgroundColor:[UIColor colorWithRed:(51/255.0) green:(51/255.0) blue:(51/255.0) alpha:1.0]];
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:(51/255.0) green:(51/255.0) blue:(51/255.0) alpha:1.0]];
所以我得到的输出如下图所示:
So i am getting the output like the below image :
另外,我在屏幕下面给出了UIButton的错位(它隐藏了20个像素)。
also i am getting misplacement of UIButtons that i have given below in my screen (It's hiding 20 pixels).
你能帮我解决一下我该如何解决这个问题?我需要输出如下图所示:
Can you please help me that how can i fix this issue? I need my output like the below image :
任何帮助都将非常感谢,谢谢。
Any help will be very appreciated, Thanks.
第三屏:
推荐答案
请在AppDelegate.h(或)constants.h中定义它。
Please define this in AppDelegate.h (or) constants.h
#define isIOS7 ([[[UIDevice currentDevice]systemVersion]floatValue] >=7.0)?YES:NO
在viewDidLoad下写下这一行。
under viewDidLoad Write this lines.
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
UIView *addStatusBar = [[UIView alloc] init];
addStatusBar.frame = CGRectMake(0, 0, 320, 20);
addStatusBar.backgroundColor = [UIColor colorWithRed:0.973 green:0.973 blue:0.973 alpha:1];
//change this to match your navigation bar
[self.window.rootViewController.view addSubview:addStatusBar];
}
或者我们可以在xib中手动更改它。
OR we can change it manually in the xib.
将每个元素向下移动20px。
By moving each element 20px down.
这篇关于iOS 7中的导航栏和状态栏问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!