我问了这个问题,但不正确。我创建了 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
接下来是我的问题:
第一个背景图像出现在状态栏下方,但您可以看到其他背景图像出现在状态栏下方。我尝试在 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/