我已经看到它在某些应用程序上完成,其中导航栏实际上小于默认的44px,并且有一个UIView(具有功能)高于导航栏...
我想要的不仅仅是自定义背景图片,我确实想知道怎么做,但我不知道从哪里开始做这样的事情。
非常感谢任何帮助:) 标记
答案 0 :(得分:3)
我找到了一种方法:
UINavigationBar *navBar = [[UINavigationBar alloc] initWithFrame: CGRectMake(0.0f, 20.0f, 320.0f, 32.0f)];
UIView *tempView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 20)];
UIImageView *back = [[UIImageView alloc] initWithImage: [UIImage imageNamed:@"logo.png"]];
[back setFrame: CGRectMake(0, 0, 320, 20)];
[tempView addSubview: back];
[[self view] addSubview: tempView];
[[self view] addSubview: navBar];
UINavigationItem *navItem = [[UINavigationItem alloc] initWithTitle: @"Controls"];
[navBar pushNavigationItem:navItem animated:NO];
这似乎可以解决问题,虽然我似乎无法弄清楚如何将这个'导入'导航控制器以便后退按钮工作,此刻我必须手动将leftBarButtonItem
插入到navItem中,后退按钮似乎永远不会显示......
答案 1 :(得分:0)
是的,你可以,
UINavigationBar *navBar = [[UINavigationBar alloc] initWithFrame: CGRectMake(0.0f, 20.0f, 320.0f, 32.0f)];
UIView *tempView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 20)];
navBar.navigationBar.layer.zPosition =-1;
self.view insertSubview:navBar atIndex:[[self.view subviews] count]];
[self.view insertSubview:tempView atIndex:[[self.view subviews] count]];