title: Strange behavior of UIBarButtonItem when using UIAppearance
body: <p>I'm customizing the elements like navigation bar, tab bar and uibarbuttonitem using UIAppearance. It works very well except for a very strange behavior of the UIBarButtonItem elements. On the top level of the navigation controller hierarchy everything looks good, but if I push the next view controller, the UIBarButtonItem elements move a little bit downwards, but at the same time, the back button stays at its correct position. I attached two images to illustrate my problem.</p>
  
  <p><strong>1) First view controller in the navigation controller hierarchy</strong></p>
  
  <p><img src="https://i.stack.imgur.com/ucVWD.png" alt="enter image description here"></p>
  
  <p><strong>2) Second view controller in the navigation controller hierarchy</strong></p>
  
  <p><img src="https://i.stack.imgur.com/lZCIs.png" alt="enter image description here"></p>
  
  <p><strong>EDIT: The code</strong></p>
  
  <pre><code>    //Change navigation bar appearance
      [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"GPNavigationBarBackground.png"] forBarMetrics:UIBarMetricsDefault];
      [[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
      [[UINavigationBar appearance] setShadowImage:[UIImage imageNamed:@"GPNavigationBarShadow.png"]];
  
      [[UINavigationBar appearance] setTitleTextAttributes:
       [NSDictionary dictionaryWithObjectsAndKeys:
        [UIColor whiteColor], UITextAttributeTextColor,
        [UIFont boldSystemFontOfSize:17], UITextAttributeFont,nil]];
      [[UINavigationBar appearance] setTitleVerticalPositionAdjustment:2.f forBarMetrics:UIBarMetricsDefault];
  
      UIImage *buttonBackground = [[UIImage imageNamed:@"GPNavigationBarButton.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 10, 0, 10)];
      UIImage *buttonPressedBackground = [[UIImage imageNamed:@"GPNavigationBarButtonPressed.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 10, 0, 10)];
  
      UIImage *backButtonBackground = [[UIImage imageNamed:@"GPNavigationBarBackButton.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 15, 0, 10)];
      UIImage *backButtonPressedBackground = [[UIImage imageNamed:@"GPNavigationBarBackButtonPressed.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 15, 0, 10)];
  
      [[UIBarButtonItem appearance] setBackgroundImage:buttonBackground forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
      [[UIBarButtonItem appearance] setBackgroundImage:buttonPressedBackground forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];
  
      [[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButtonBackground forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
      [[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButtonPressedBackground forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];
  
      [[UIBarButtonItem appearance] setBackButtonBackgroundVerticalPositionAdjustment:1.f forBarMetrics:UIBarMetricsDefault];
      [[UIBarButtonItem appearance] setBackgroundVerticalPositionAdjustment:1.f forBarMetrics:UIBarMetricsDefault];
      [[UIBarButtonItem appearance] setTitlePositionAdjustment:UIOffsetMake(0, 1.f) forBarMetrics:UIBarMetricsDefault];
  </code></pre>