Neha Gupta
Neha Gupta

Reputation: 291

Show View on the top of navigation bar

I have a custom navigation and Home view in my app. On the click of button I want to show a View just like a left side view ( width is not equal to screen width) , on the top of navigation. I have tried this:

LeftView.Layer.ZPosition = 1;

It is not working. If I set the Z index of navigation to -1, this hides complete navigation bar.

enter image description here

Upvotes: 2

Views: 1865

Answers (4)

Anil shukla
Anil shukla

Reputation: 277

This is a correct answer:

[self.navigationController.view addSubview:yourSubView];

Though it will not set the correct frame for the view, To set the correct frame for your view on the navigation bar, you have to set it in the viewDidAppear.

-(void)viewDidAppear:(BOOL)animated
{
   [super viewDidAppear:animated];  
   [self.navigationController.view addSubview:mTitleView];
}

Upvotes: 0

NightFury
NightFury

Reputation: 13546

Add your custom navigation bar to the main view manually instead of using navigation controller's standard navigation bar. Then add your leftview as subview, in your main view. It will overlap navigation bar in this hierarchy.

Upvotes: 0

Balaji Ramakrishnan
Balaji Ramakrishnan

Reputation: 1949

Try to add that view to UIWindow. This will add your view above navigation bar.

[[[[UIApplication sharedApplication] delegate] window] addSubview:yourView];

Upvotes: 2

TheAppMentor
TheAppMentor

Reputation: 1099

Try this :

[self.navigationController.view addSubview:yourSubView];

Upvotes: 3

Related Questions