带有其他视图的ios 6上的重叠导航栏 [英] Overlap navigation bar on ios 6 with other view

查看:123
本文介绍了带有其他视图的ios 6上的重叠导航栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于具有独特"设计的iPhone项目(我一点都不满意),我需要绘制一个自定义视图,该视图与UINavigationController中的控制器的导航栏部分重叠.目标是具有固定设备方向(人像)的iphone/ios 6.

For an iphone project with an "unique" design (with which i am not happy at all) I need to draw a custom view which partially overlaps the navigation bar of a controller in a UINavigationController. Target is iphone/ios 6 with a fixed device orientation (portrait).

我当前的解决方案是通过控制器的viewDidLoad中的self.navigationController.navigationBar.hidden = YES;以编程方式禁用导航栏,并绘制伪"导航栏并在其上绘制. 这导致状态栏颜色保持黑色(因为没有可见的实际导航栏). 此处讨论了ios 6状态栏颜色: iOS 6中的状态栏颜色?

My currents solution is to disable the navigation bar programatically via self.navigationController.navigationBar.hidden = YES; in viewDidLoad of my controller and to draw a "fake" navigation bar and paint over this. This leads to the problem that the status bar color remains black (since there is no real navigation bar visible). Ios 6 status bar color is discussed here: Status bar color in iOS 6?

我已经尝试使用[self.view insertSubview:OVERLAPVIEW aboveSubView:self.navigationController.navigationBar],但是它不起作用,并且OVERLAPVIEW被绘制在导航栏下方.

I already tried to use [self.view insertSubview:OVERLAPVIEW aboveSubView:self.navigationController.navigationBar] but it did not work and OVERLAPVIEW was drawn beneath the navigation bar.

是否有另一种方法可以将导航栏与另一个视图重叠(z方向)? 或者,当没有显示导航栏时,是否有一种方法可以更改状态栏的颜色(不幸的是,除此之外,重叠的视图是应用程序的主视图和用户可以看到的第一个屏幕)

Is there another way to overlap the navigation bar with another view (z-wise)? Or is there a way to change the status bar color when no navigation bar is shown (unfortunately in addition to this the view with the overlap is the main view of the app and the first screen visible to the user)

全面披露:我是ios noob和堆栈溢出潜伏者-这是我对堆栈溢出的第一个问题,请帮助我澄清我的问题,并在必要时提高我的堆栈溢出技能.

Full disclosure: I am an ios noob and stack overflow lurker - this is my first question on stack overflow, please help me to clarify my question and improve my stack overflow skills if necessary.

推荐答案

我通过隐藏导航栏来解决此问题

I solved this issue by hiding the Navigation bar with

self.navigationController.navigationBar.hidden = YES;

,然后在我的视图中添加一个导航栏.在此新导航栏之后添加的所有内容都将与之重叠(您也可以使用索引[parentView.subviews objectAtIndex:0];). 状态栏的颜色根据需要更改.

and by adding a navigation bar to my view. Everything added after this new navigation bar will to overlap it (you could use index [parentView.subviews objectAtIndex:0]; as well). The color of the status bar changes as needed.

在启动屏幕的情况下,我的操作完全相同,并将导航栏与全屏启动图像重叠.

In the case of the splash screen i do exactly the same and overlap the navigation bar with the fullscreen splash image.

-(void)viewDidLoad{
    [super viewDidLoad];
    UINavigationBar * navigationBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 320, 49)];
    UINavigationItem *item = [[UINavigationItem alloc] initWithTitle:@"SPLASH"];
    [navigationBar pushNavigationItem:item animated:NO];
    [self.view addSubview:navigationBar];

    CGRect frame = [[UIScreen mainScreen] bounds];
    frame.origin.y -= 20;
    UIImageView *splashImage = [[UIImageView alloc] initWithFrame:frame];
    splashImage.image = [UIImage imageNamed:@"splash"];
   [self.view addSubview:splashImage];
}

这篇关于带有其他视图的ios 6上的重叠导航栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆