导航控制器栏正在被切断

时间:2013-09-13 04:00:22

标签: ios objective-c uinavigationcontroller ios7

如果通过选择status bar style = hide during application launch隐藏状态栏,我正在自定义uinavigation栏,如下所示

[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed: @"navbar-iphone.png"]
                                       forBarMetrics:UIBarMetricsDefault];

当我得到这个时:导航栏被切掉了顶部。

enter image description here

enter image description here

关于这种情况的任何想法以及如何解决它?

1 个答案:

答案 0 :(得分:0)

你可以试试这个。

在应用程序启动期间。这里viewController是UINavigationController。

//set status bar hidden true.
    [[UIApplication sharedApplication]setStatusBarHidden:YES]; 

//You can set navigation bar frame to start from 0.0,0.0
    self.viewController.navigationBar.frame = CGRectOffset(self.viewController.navigationBar.frame, 0.0, -20.0);

//set the image u want.
    [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed: @"navbar-iphone.png"]
                                       forBarMetrics:UIBarMetricsDefault];

[[UIApplication sharedApplication]setStatusBarHidden:YES]; 
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed: @"navbar-iphone.png"]
                                           forBarMetrics:UIBarMetricsDefault];
[self.viewController setWantsFullScreenLayout:YES];