0

I am creating an iPad application for ios 5 using arc and storyboard in xcode 4.3. I need to customize the UInavigationbar to make it broader than its usual size (almost double sized) and add to it some custom logos (images) and buttons. Can anyone pls point me in the correct direction on how this can be acheived? any third party libraries are also welcome if required.

Thanks in advance for your help on this one.

inforeqd
  • 3,209
  • 6
  • 32
  • 46

2 Answers2

2

To start, you'll want to subclass UINavigationBar. While it is possible to change the height, the UINavigationBar background isn't going to play nicely, so you'll probably want to use your own background image.

Here's some information about resizing the navigation bar

Change the height of NavigationBar and UIBarButtonItem elements inside it in Cocoa Touch

iPhone - How set uinavigationbar height?

And another article on how to add the images and buttons as subviews.

http://www.iosdevnotes.com/2011/09/custom-uinavigationbars-techniques/

Community
  • 1
  • 1
Brandon Schlenker
  • 5,078
  • 1
  • 36
  • 58
  • the articles don't mention how can I set the new height in ARC environment. Am sure I'm missing something. Can you pls help? – inforeqd Mar 04 '12 at 07:35
  • ARC, automatic reference counting, deals with memory management. The only difference is that retain/release are handled automatically. Just remove any release, autorelease, retain, etc as Xcode will prompt you to do, and you'll be fine. – Brandon Schlenker Mar 04 '12 at 09:56
  • you are a lifesaver! for iOS 5.0. I subclassed the UINavigationabar then I implemented :sizeThatFits to increase the size and drawRect to create a custom bar from an image. `@interface CustomNavigationBar : UINavigationBar @end #import "CustomNavigationBar.h" @implementation CustomNavigationBar - (CGSize)sizeThatFits:(CGSize)size { CGSize newSize = CGSizeMake(self.frame.size.width,175); return newSize; } - (void)drawRect:(CGRect)rect { UIImage *image = [UIImage imageNamed:@"navigationbar.png"]; [image drawInRect:CGRectMake(0, 0, rect.size.width, rect.size.height)]; } @end` – inforeqd Mar 04 '12 at 11:29
0

I don′t know how you would change the size of the UINavigation bar. To add custom buttons you can outlet your navigationItem in the storyboard to the interface of your view controller. Then use setLeftBarButtonItems: and setRightBarButtonItems: to put multiple buttons you previously created.

To add custom black and white logos to the buttons you can use [navigationButtonItem setBackgroundImage: yourImage].

If you want your logos in color you can create a UIButton with the colored logo ([newButton setImage: yourImage]) and then init your navigation button item with : initWithCustomView: newButton.