UINavigationBar custom title being hidden by background
I am adding a custom UIImageView
to my UINavigationBar
using this code:
UIImageView *background = [[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 44)] autorelease];
[background setImage:[UIImage imageNamed:@"nav_background.png"]];
[background setTag:kTagForReference];
[self.navigationController.navigationBar insertSubview:background atIndex:0];
I then add a custom title using this code:
UILa开发者_如何转开发bel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 400, 44)];
...
[self.navigationItem setTitleView:label];
[label release];
But on some of my pushed views the title is being hidden (or isn't visible). I can't seem to push more than two views onto the stack without the title disappearing.
I've tried to force my UIImageView
background to the back of the bar but that still doesn't help. I've printed the subviews of the UINavigationBar
and I can see that the UILabel is there, I just can't see it!
Any help would be greatly appreciated.
If you can run the dumpWindows() function, the output would show the view hierarchy so you can see what view is covering it up.
You most likely want to use a UIToolBar
instead of a NavigationBar
. Then you can add the subviews to the UIToolbar
.
Bring the UILabel to the front most view.
[self.view bringSubviewToFront: label];
精彩评论