title: iPhone UINavigationBar - Set width and margin of rightBarButtonItem
body: <p>I have a background image for a button, with the dimensions of 80x30 pixels.</p>
  
  <p>I use the code below to set the background in my view-controller, and the result is this:</p>
  
  <p><img src="https://i.stack.imgur.com/Qt6OZ.png" alt="Top and corners are noisy"></p>
  
  <p>As you can see, the corners and the top of the right button is messed up.</p>
  
  <pre><code>- (void)viewDidLoad
  {
      [super viewDidLoad];
      // Do any additional setup after loading the view.
  
      UIImage *favoriteBtnImgNormal = [[UIImage imageNamed:@"favorite-btn-normal"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 30, 30, 0)];
      UIImage *favoriteBtnImgTouch = [[UIImage imageNamed:@"favorite-btn-touch"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 30, 30, 0)];
  
      [self.navigationItem.rightBarButtonItem setBackgroundImage:favoriteBtnImgNormal forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
      [self.navigationItem.rightBarButtonItem setBackgroundImage:favoriteBtnImgTouch forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];
      [self.navigationItem.rightBarButtonItem setBackgroundImage:favoriteBtnImgTouch forState:UIControlStateSelected barMetrics:UIBarMetricsDefault];
      [self.navigationItem.rightBarButtonItem setTitlePositionAdjustment:UIOffsetMake(-10.0, 0.0) forBarMetrics:UIBarMetricsDefault];
  }
  </code></pre>
  
  <p>Note that I do this in a single view-controller, I use the appearance API to set general styles. But here I want to override the general appearance.</p>
  
  <p>If I just get the images without the resizable-stuff, it looks like this:</p>
  
  <p><img src="https://i.stack.imgur.com/5zU3Q.png" alt="Too large"></p>
  
  <p>Now the edges and corners are fine, but the button is too large.</p>
  
  <p>I'm sure I'm doing this all wrong, so I need someone to point out what I could do to scale buttons correctly?</p>