title: Custom UINavigationBar's backButton?
body: <p>I am making a iPhone app that allows the user to go back in a UINavigationBar. However, the way it looks now is horrendous. I am trying to customize it with my own image (minus the default UIBarButtonItem background). My image includes my custom background, but you can still see part of the button on the left and the right.</p>
  
  <pre><code>UIBarButtonItem *cancelButton = [[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"back_button_normal.png"] style:UIBarButtonItemStylePlain target:self   action:@selector(cancel:)] autorelease];
  self.navigationItem.leftBarButtonItem = cancelButton;  
  </code></pre>
  
  <p>Is there a way to remove that space? Is there a possibility I can use a UIButton so I can customize it completely? I did something in interface builder where i dragged a UIButton into the UINavigationBar's rightButton and it works perfectly. Is there anyway I can do it programmatically?</p>
  
  <p>Thanks!</p>
  
  <p>Here's how it looks:</p>
  
  <p><img src="https://i.stack.imgur.com/eVlos.png" alt="UINavigationBar"></p>
  
  <p>EDIT #1:</p>
  
  <pre><code>UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
  [button addTarget:self action:@selector(cancel:) forControlEvents:UIControlEventTouchDown];
  [button setTitle:@"Show View" forState:UIControlStateNormal];
  [button setBackgroundImage:[UIImage imageNamed:@"back_button_normal.png"] forState:UIControlStateNormal];
  
  UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
  [self.navigationItem setLeftBarButtonItem:barButtonItem];
  </code></pre>
  
  <p>Here's how I make my background for the UINavigationBar (places in my RootViewController):</p>
  
  <pre><code>@implementation UINavigationBar (UINavigationBarCustomDraw)
  
  - (void) drawRect:(CGRect)rect {
  
  [self setTintColor:[UIColor colorWithRed:0.85f green: 0.85f blue:0.85f alpha:1]];
  
  if ([self.topItem.title length] &gt; 0 &amp;&amp; ![self.topItem.title isEqualToString:@"Back to ..."]) {
      [[UIImage imageNamed:@"UINavigationBar_background.png"] drawInRect:rect];
  
      CGRect frame = CGRectMake(0, 0, 320, 44);
      UILabel *label = [[[UILabel alloc] initWithFrame:frame] autorelease];
      [label setBackgroundColor:[UIColor clearColor]];
      label.font = [UIFont boldSystemFontOfSize: 20.0];
      label.shadowColor = [UIColor colorWithWhite:0.0 alpha:1];
      label.textAlignment = UITextAlignmentCenter;
      label.textColor = [UIColor whiteColor];
      label.text = self.topItem.title;
      self.topItem.titleView = label;
  
  } else {
      [[UIImage imageNamed:@"login_button.png"] drawInRect:rect];
      self.topItem.titleView = [[[UIView alloc] init] autorelease];
  }
  }
  
  @end
  </code></pre>