Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>WARNING:</strong> There are reports that this will not work on iOS 6. This might only work on older versions of the OS. Evidently at least one dev has had their app rejected for using this trick (see the comments). Use at your own risk. Using an image (see answer above) might be a safer solution.</p> <p>This can be done without adding in your own image files using sekr1t button type 101 to get the correct shape. For me the trick was figuring out that I could use <code>initWithCustomView</code> to create the <code>BarButtonItem</code>. I personally needed this for a dynamic navbar rather than a <code>toolbar</code>, but I tested it with a toolbar and the code is nearly the same:</p> <pre><code>// create button UIButton* backButton = [UIButton buttonWithType:101]; // left-pointing shape! [backButton addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside]; [backButton setTitle:@"Back" forState:UIControlStateNormal]; // create button item -- possible because UIButton subclasses UIView! UIBarButtonItem* backItem = [[UIBarButtonItem alloc] initWithCustomView:backButton]; // add to toolbar, or to a navbar (you should only have one of these!) [toolbar setItems:[NSArray arrayWithObject:backItem]]; navItem.leftBarButtonItem = backItem; </code></pre> <p>If you're doing this on a toolbar you'll have to tweak how you set the items, but that depends on the rest of your code and I leave that as an exercise for the reader. :P This sample worked for me (compiled &amp; run).</p> <p>Blah blah, read the HIG, don't use undocumented features, and all that. There's only six supported button types and this isn't one of them.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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