title: iOS: Positioning navigation bar buttons within custom navigation bar
body: <p>I'm building an app with a custom navigation bar. After some research I decided to do this using a category on UINavigationBar. The navigation bar needs to be a bit larger than usual to accomodate a drop shadow. Here is the code:</p>
  
  <pre><code>#import "UINavigationBar+CustomWithShadow.h"
  
  @implementation UINavigationBar (CustomWithShadow)
  
  - (void)drawRect:(CGRect)rect {
  
      // Change the tint color in order to change color of buttons
      UIColor *color = [UIColor colorWithHue:0.0 saturation:0.0 brightness:0.0 alpha:0.0];
      self.tintColor = color;
  
      // Add a custom background image to the navigation bar 
      UIImage *image = [UIImage imageNamed:@"NavBar.png"];
      [image drawInRect:CGRectMake(0, 0, self.frame.size.width, 60)];
  }
  
  - (void)layoutSubviews {
  
      self.frame = CGRectMake(0, 20, self.frame.size.width, 60);
  }
  @end
  </code></pre>
  
  <p>The only problem now is that the larger navigation bar means that the navigation bar buttons end up too far down, like so:</p>
  
  <p><img src="https://i.stack.imgur.com/48o4f.png" alt="enter image description here"></p>
  
  <p>Does anyone know how I can correct the position of the buttons? </p>
  
  <p>Thanks for all help!</p>
  
  <p><strong>Update:</strong></p>
  
  <p>I add the buttons to the nav bar in the init method of the view controller like so:</p>
  
  <pre><code>// Create "Add" button for the nav bar
  UIBarButtonItem *addButton = [[UIBarButtonItem alloc] 
      initWithBarButtonSystemItem:UIBarButtonSystemItemAdd 
      target:self 
      action:@selector(createNewEntry:)];
  [[self navigationItem] setRightBarButtonItem:addButton];
  [addButton release];
  </code></pre>