Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>55As commented above, the solution I went with is based on this answer to a different, but very much related question: <a href="https://stackoverflow.com/questions/6021138/how-to-adjust-uitoolbar-left-and-right-padding/7042201#7042201">How to adjust UIToolBar left and right padding</a>. It is also facilitated by (and depends on) iOS5, which allows you to set multiple buttons on the left or right side, instead of just one.</p> <p>Here's an example of removing the padding to the left of a custom left button item:</p> <pre><code>UIBarButtonItem *backButtonItem // Assume this exists, filled with our custom view // Create a negative spacer to go to the left of our custom back button, // and pull it right to the edge: UIBarButtonItem *negativeSpacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil]; negativeSpacer.width = -5; // Note: We use 5 above b/c that's how many pixels of padding iOS seems to add // Add the two buttons together on the left: self.navigationItem.leftBarButtonItems = [NSArray arrayWithObjects:negativeSpacer, backButtonItem, nil]; </code></pre> <p>And with this, the left padding for the left bar button item in a navigation bar, is gone!</p> <p><strong>NOTE</strong>: This has worked for me in iOS5 and iOS6. Given that iOS7 is considerably different (from the public demos), those of you with the early seeds of iOS7 should test if something so unintentional, like this hack, will actually continue to work for you beyond iOS6.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload