Adding images to buttons in interface builder
Asked Answered
P

3

7

I want to add an image to my button instead of text. Can I do this in interface builder? Any example I can look at?

Thanks Deshawn

Pinwork answered 13/6, 2011 at 16:14 Comment(2)
its literally the option below "title" on a UIButton in interface builder. its called "image", alternatively, there is the "backgroundImage" property that is right below these.Binkley
Sorry but I dont see a title option anywhere... I am using Xcode 4 and when I highlight my button, I dont see any option for title.Pinwork
M
13

1:select the button

2:select Attributes Inspector

3:change type to Custom

4:There are two ways to do this using the interface builder

-1: Make a button image->include it in your project->set the image as the "image" of the button.

-2: Make a button background image->include it in your project->set the image as the "background" of the button->set the "Title" of the button to anything you want.

Mobley answered 1/5, 2012 at 22:22 Comment(1)
you need to change type to custom after setting image as wierd things happen if you don't do soMontague
R
4
  1. Add the image in your project.
  2. In IB set the button type to custom.
  3. Set the image in Image or Background box just below the Title box.

That's all.

Rollback answered 13/6, 2011 at 16:29 Comment(2)
Isn't there a drop down menu where rounded rect button is selected by default? Which SDK version you are using?Rollback
There are some major change in IB look-and-feel in SDK 4. Can you see the inspector for menu?Rollback
C
1

I actually had to drag and drop the images folder into the Project Navigator and chose that the folder is a reference and only then, I could see the images in the Media Library.

From there the only thing you need to do is drag the picture where you want or change for the image name in the Attribute inspector.

Cacilie answered 13/7, 2015 at 11:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.