ios - navigationBar出现在statusBar下面

标签 ios objective-c uinavigationcontroller uinavigationbar

我问了这个问题,但不正确。我创建了 NavigationVC Controller :

#import <UIKit/UIKit.h>
@interface NavigationVC : UINavigationController

- (void)setTitleText:(NSString *)title calendar:(BOOL)calendar moveToLeft:(BOOL)left;
 //this method for create title of navigationitem that I then use in all ViewControllers

@end

在 NavigationVC.m 中我有:

@implementation NavigationVC

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
  self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
  if (self) {
    // Custom initialization
}
  return self;
}

- (void)awakeFromNib
{
   [self.navigationBar setBackgroundImage:[UIImage imageNamed:@"backGroundLayer.png"] forBarMetrics:UIBarMetricsDefault];
}

- (void)viewWillAppear:(BOOL)animated
{
  [super viewWillAppear:animated];

}

- (void)viewDidLoad
{
  [super viewDidLoad];

}

图像 backGoundLayer.png 的分辨率为 320x44,我的 backGround@2x.png 分辨率为 640x88

我创建了继承自 UIViewController 的 View Controller BaseVC,以及继承自 BaseVC 的其他 View Controller 。

我在 Storyboard中创建了我的 Nib

enter image description here

接下来是我的问题:

enter image description here

第一个背景图像出现在状态栏下方,但您可以看到其他背景图像出现在状态栏下方。我尝试在 Storyboard 中将 statusBar 更改为黑色,但这对我没有帮助。我试试写法

[self.navigationBar setBackgroundImage:[UIImage imageNamed:@"backGroundLayer.png"] forBarMetrics:UIBarMetricsDefault];

 In viewDidLoad or viewWillAppear in NavigationVC, but it not helped too.

我还有第二个问题。 我在 viewcontroller 中创建按钮,当它触及时我按下一个 View 。我以编程方式将标题添加到第一个 View 和第二个 View 。当我触摸按钮时,我在第二个 View 的瞬间标题中看到(这个标题比它必须的,我认为背景出现没有状态栏),然后第二个 View 的标题消失,我看到空的导航栏。当我单击 backButton 并转到第一个 View 时,我在第一个 View 上看到第二个 View 的导航栏标题。什么问题?

最佳答案

这是 iOS 6 的特性,默认情况下状态栏采用导航栏的颜色。您可以通过更改目标摘要页面上的状态栏样式来更改此行为。

关于ios - navigationBar出现在statusBar下面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15379879/

相关文章:

ios - IB : adding constraint related to a second view 中的自动布局

ios - PushViewController 两次当我双击太快时

ios - 不鼓励在分离的 View Controller 上呈现 View Controller - "detached view controller"的定义?

ios在应用程序中购买消耗品设计指南问题

objective-c - 返回大值的 NSUserAppleScriptTask 从不调用completionHandler

objective-c - 按下UIButton后,在设置的延迟后播放声音

ios - 为什么我的自动布局 ViewController 放在 NavigationController 中时显示不正确?

ios - 如何在每个 View 上添加 UISearchbar

ios - 从背景恢复后,Chirp Audio QR无法在ipad上接收音频信号

iphone - Objective-C : Detecting change in accelerometer