title: Custom UIBarButtonItem alignment off with iOS7
body: <p>So I am having the same problem that many others are experiencing when creating a UIBarButtonItem with a UIButton as a custom view.</p>
  
  <p>Basically the button is about 10 pixel to far either left or right. When I use a regular BarButtonItem without a custom view, this does not happen. </p>
  
  <p>This post provided a partial solution:
  <a href="https://stackoverflow.com/questions/18861201/uibarbuttonitem-with-custom-view-not-properly-aligned-on-ios-7-when-used-as-left">UIBarButton With Custom View</a></p>
  
  <p>Here is my code I have created by subclassing UIButton (as stated in the other post)</p>
  
  <pre><code>    - (UIEdgeInsets)alignmentRectInsets {
      UIEdgeInsets insets;
      if ([self isLeftButton]) {
          insets = UIEdgeInsetsMake(0, 9.0f, 0, 0);
      }
      else { // IF ITS A RIGHT BUTTON
          insets = UIEdgeInsetsMake(0, 0, 0, 9.0f);
      }
      return insets;
  }
  
  
  - (BOOL)isLeftButton {
      return self.frame.origin.x &lt; (self.superview.frame.size.width / 2);
  }
  </code></pre>
  
  <p>This works great, but when I pop a view controller from the navigation controller back to this main view, the button is still incorrectly positioned for about .3 seconds, and then it snaps into the correct inset. </p>
  
  <p>This is a HUGE eyesore and I have no idea how to stop it from snapping like so. Any thoughts? Thanks!</p>