views:

4129

answers:

6

I have tried this approach/hack: http://blog.blackwhale.at/2009/06/uibuttons-in-uinavigationbar/

The problem is this leaves a faint seam. I tried setting the background image of the nested toolbar to an image I captured of what it should be. That didn't work. The image was not applied. I have also tried using a nested UINavigationBar and that didn't seem to work.

I have seen this done in several iPhone apps. Does anyone know how?

[EDIT] I want the buttons to look like normal UIBarButtonItems and be able to use system styles like UIBarButtonSystemItemAdd, UIBarButtonSystemItemRefresh. The link I provided does this except you can see a faint seam because it is a UIToolbar nested in the navigationbar..

Please don't mention this breaking the Human Interface Guidelines. (We know).

I appreciate you contributing your hacks... thats the only way to do this!

+2  A: 

see uicatalogue example available at apple's site for free...they used uisegmented control to show three buttons in place of right bar button on navigaion bar...

Rahul Vyas
Sorry. I'm not looking for a segment control. I want the standard buttons like + (add button), Edit, refresh icon and so on.
Cal
you can add a custom view with your desired buttons...search google for the custom view code..you'll be able to get it
Rahul Vyas
there are many tutorial on net to do this.if you've tried post your code
Rahul Vyas
I looked into it again and I think this way is actually pretty good. The only problem is getting the standard icons if you need them. The segment control buttons look like normal navigation buttons if you do this.
Cal
BTW I didn't see the example you were talking about. I have a different version of the UICatalog project I guess. I did see it in the Interface Builder. You can drop the segment control onto the naviation bar left/right/center.
Cal
+1  A: 
UIView *parentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, myWidth, myHeight)];
// make UIView customView1... (UILabel, UIButton, etc.) with desired frame and settings
[parentView addSubview:customView1];
[customView1 release];
// make UIView customView2... (UILabel, UIButton, etc.) with desired frame and settings
[parentView addSubview:customView2];
[customView2 release];
UIBarButtonItem *customBarButtomItem = [[UIBarButtonItem alloc] initWithCustomView:parentView];
[parentView release];
self.navigationItem.rightBarButtonItem = customBarButtomItem;
[customBarButtomItem release];
Alex Reynolds
I want the buttons to look like normal UIBarButtonItems and be able to use system styles like UIBarButtonSystemItemAdd, UIBarButtonSystemItemRefresh. The link I provided does this except you can see a faint seam because it is a UIToolbar nested in the navigationbar.
Cal
alex answer works for you perfectly
Rahul Vyas
I tried this before and the button looks different. But you can take a screenshot image of the look you want and use that in the button.
Cal
+1  A: 

To get rid of the background ('seam') of a UIToolbar, create a subclass of UIToolbar and override the (void)drawRect:(CGRect)rect method. Leave that blank and your UIToolbar will no longer have a background.

Just used this in my own project and worked great. Found this in the comments of: http://osmorphis.blogspot.com/2009/05/multiple-buttons-on-navigation-bar.html

iworkinprogress
A: 

I can't comment but in addition to @iworkinprogress I had to set the UIToolbar background color to clear:

    [toolbar setBackgroundColor:[UIColor clearColor]];

This was also found in the comments of http://osmorphis.blogspot.com/2009/05/multiple-buttons-on-navigation-bar.html.

Evan