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.
I was trying to do the same thing, but I wanted the back button to be in the navigation bar. (I actually needed a back button, that would do more than only going back, so I had to use the leftBarButtonItem property). I tried what AndrewS suggested, but in the navigation bar it wouldn't look the way it should, as the UIButton was kind of casted to a UIBarButtonItem.
But I found a way to work around this. I actually just put a UIView under the UIButton and set the customView for the UIBarButtonItem. Here is the code, if somebody needs it:
Try this. I am sure you do not need a back button image to create one such.
That's all you have to do :)
Well, you don't have to have a different button for every size, you can use
[UIImage stretchableImageWithLeftCapWidth:topCapHeight:]
, but the only thing I've found is custom images.Example in Swift 3, with a previous and a next button in the top right.
If you don't want to bother with image files, the arrow shape can be drawn in a UIView subclass with the following code:
where the arrow view is proportional to a width of 6.0 and a height of 10.0
It's easy to do with Interface Builder in Xcode 5.x
use Toolbar and Bar Button Item from Object library
in button's Attributes inspector edit Image section with your back button image
Done!