Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-05-2010, 08:21 PM   #1 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 13
markkram is on a distinguished road
Default Can you add a UIView above a UINavigationBar?

I have seen it done on some apps, where the navigation bar is actually smaller than the default 44px, and there is a UIView (which has functionality) above the nav bar...

I want more than a custom background image, which I did manage to figure out how to do, but I dont know where to start getting something like this done.

Any help is greatly appreciated
Mark
markkram is offline   Reply With Quote
Old 08-05-2010, 09:37 PM   #2 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 107
JDave is on a distinguished road
Default

When you say 'above' do you mean "on-top" or between the statusbar and navbar?

Have a look at apple's docs if you mean "on-top":
View Controller Programming Guide for iOS: Navigation Controllers
if the above link does not go straight to "Customizing the Navigation Bar Appearance", then select that from the left column. Also from this link have a look at "Listing 3-2 Creating custom bar button items"... They have a good sample code for putting in a segmented controller instead of a rightbarbutton. Just omit the line:

Code:
defaultTintColor = [segmentedControl.tintColor retain];    // keep track of this for later
in apple's sample code to got a prelim version up and running (you will also need two pics named up.png and down.png if you copy apple's code verbatim), as I don't think apple/iOS gives you access to the ones used in the mail app.

Based on the apple sample code in the link, the key to customizing the navbar button is in this line:
Code:
UIBarButtonItem *segmentBarItem = [[UIBarButtonItem alloc] initWithCustomView:segmentedControl];
where initWithCustomView: is attached to a UISwitch, UIView, UIButton, etc...

Good luck.

Last edited by JDave; 08-05-2010 at 09:43 PM.
JDave is offline   Reply With Quote
Old 08-06-2010, 04:44 AM   #3 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 13
markkram is on a distinguished road
Default

Thanks JDave, I did actually mean "between the statusbar and navbar" and I managed to find out how to do it too:

Code:
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];
Which seemed to do the trick, although I couldnt really figure out how to incoroporate this into the UINavigationController so that it adds back buttons and such, but I think this will do for now
markkram is offline   Reply With Quote
Old 08-06-2010, 06:41 AM   #4 (permalink)
Registered Member
 
Join Date: Aug 2009
Posts: 105
vamsi.ac is on a distinguished road
Default

u can hide the uinavigation bar if u need..
vamsi.ac is offline   Reply With Quote
Old 08-08-2010, 07:00 PM   #5 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 107
JDave is on a distinguished road
Default

Awesome, thanks for the feedback!
JDave is offline   Reply With Quote
Reply

Bookmarks

Tags
iphone, uinavigationbar

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 308
11 members and 297 guests
alexP, arash5500, gordo26, HemiMG, linkmx, mediaspree, nobstudio, Objective Zero, Sloshmonster, stanny, Touchmint
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,655
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, pungs
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 11:28 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0