I'd love to create a "back" left-arrow-bezel button in a UIToolbar
.
As far as I can tell, the only way to get one of these is to leave UINavigationController
at default settings and it uses one for the left bar item. But there's no way I can find to create one as a UIBarButtonItem
, so I can't make one in a standard UIToolbar
, even though they're very similar to UINavigationBar
s.
I could manually create it with button images, but I can't find the source images anywhere. They have alpha-channel edges, so screenshotting and cutting won't get very versatile results.
Any ideas beyond screenshotting for every size and color scheme I intend to use?
Update: PLEASE STOP dodging the question and suggesting that I shouldn't be asking this and should be using UINavigationBar
. My app is Instapaper Pro. It shows only a bottom toolbar (to save space and maximize readable content area), and I wish to put a left-arrow-shaped Back button in the bottom.
Telling me that I shouldn't need to do this is not an answer and certainly doesn't deserve a bounty.
Swift
Here's what I ended up doing after searching through all these solutions and others. It uses a stretchable png's extracted from the UIKit stock images. This way you can set the text to whatever you liek
The Unicode Method
I think it is much easier to just use a unicode character to get the job done. You can look through arrows by googling either Unicode Triangles or Unicode Arrows. Starting with iOS6 Apple changed the character to be an emoji character with a border. To disable the border I add the 0xFE0E Unicode Variation Selector.
The code block is just for the demo. It would work in any button that accepts an NSString.
For a full list of characters search Google for Unicode character and what you want. Here is the entry for Black Left-Pointing Triangle.
Result
To create an image for the UIToolbar, make a png in photoshop and WHERE EVER there is ANY colour it puts it white, and where it's alpha = 0 then it leaves it alone.
The SDK actually put's the border around the icon you have made and turns it white without you having to do anything.
See, this is what I made in Photoshop for my forward button (obviously swap it around for back button):
http://twitpic.com/1oanv
and this is what it appeared like in Interface Builder
http://twitpic.com/1oaoa
I'm not sure if this would work, but you could try creating a
UINavigationController
with the default settings to create the button, find the button in the navigation controller's subview hierarchy, callremoveFromSuperview
on it, destroy the navigation controller, and then add the button as a subview of your toolbar. You may also need toretain
and the button before callingremoveFromSuperview
(and thenrelease
it after adding it as subview of your toolbar) to avoid it being deallocated during the process.