2012-03-19 135 views
0

我正在创建一个应用程序,我必须使用导航图像。 没有导航的图像,我可以看到工具栏选项完美工具栏隐藏导航图像

的应用,而无需像

导航栏启动,主屏幕 navigation bar without image at app start up-home screen

导航图像后,导航到第二页 navigation image after navigate to second page

现在我加入了一个图像在我的导航栏中使用

UIImageView *topBar = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 768, 45)]; 
topBar.image = [UIImage imageNamed:@"top_cell.png"]; 
[self.navigationController.navigationBar addSubview:topBar]; 

现在导航栏看起来像在主屏幕完美

navigation image after adding image

但在第二页的工具栏选项隐藏hidden toolbar

所以我怎样才能显示工具栏导航栏以上的图像?

回答

0

[self.navigationController.navigationBar insertSubview:topBar belowSubview:navigationBar]; 

尝试,它将插入您的导航栏下您的看法。

第二个选择是后你使用此代码:

[self.navigationController.navigationBar bringSubviewToFront: topBar] 

,将你放在最上面一栏的视图堆栈的顶部。

+0

感谢您的答复... – Hiren 2012-03-19 09:18:25

0

终于大量的工作我找到了解决办法首先我必须添加图像viewWillAppear方法再经过我在viewDidAppear方法添加我的工具栏,就像下面的代码

-(void)viewWillAppear:(BOOL)animated 
{ 
// self.navigationController.navigationBarHidden = TRUE; 


///// Edit Hiren 

UIImageView *topBar = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 1024, 45)]; 
topBar.image = [UIImage imageNamed:@"top-bar.png"]; 
[self.navigationController.navigationBar addSubview:topBar]; 


} 

-(void)viewDidAppear:(BOOL)animated 
{ 
    toolbar.frame = CGRectMake(0, 0, 685, 44); 
    // [toolbar sizeToFit]; 
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:toolbar]; 
    // [self.navigationController.view addSubview:toolbar]; 

}