How to add UIBarButtonItem to UIToolbar with both text and image?

How to add UIBarButtonItemin UIToolbarboth text and image? Take a look at the image that I will show. This is exactly what I'm trying to do.

Here's the image

+5
source share
4 answers

First of all, create a UIButton with an image and a name.

Then add this button to BarButtonItem

UIBarButtonItem *barButton = [[UIBarButtonItem alloc] initWithCustomView:customButton];
+6
source

add a custom toolbar for the toolbar, set this property to this button, add a label to the button for text

button.contentHorizontalAlignment =  UIControlContentHorizontalAlignmentLeft;
+1
source

You must create UIViewwith UILabeland UIImageas subzones. Then create UIBarButtonItemwith a custom view:

UIBarButtonItem *barButton = [[UIBarButtonItem alloc] initWithCustomView:customView];
0
source

Several link links will help you embed the UIBarButtonItem in a UIToolbar with text and image .... You simply change the code to suit your requirements.

0
source

All Articles