Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between setBackgroundImage:Forstate and setImage:Forstate:

I am trying to set a image for a UIButton.

I don't know the difference between the setBackgroundImage:Forstate and setImage:Forstate:

Could anyone help me out?

Thanks and best regards.

like image 684
shashoukou Avatar asked May 06 '11 09:05

shashoukou


2 Answers

  1. setImage:forState: sets the image as the actual content of the button. For example, you can not see the button title even though you set it, because you have set an image as the content.

  2. setBackgroundImage:forState: sets the image as the background. In this case, you can set the title and it is displayed on top of the image.

like image 89
EmptyStack Avatar answered Oct 24 '22 22:10

EmptyStack


setBackgroundImage: follows the frame, i.e. if u change the frame, the background image is streched or shrinked with it. Contrary on the setImage, its not the same. The image takes its own size. In setImage the image is the actual content of the button.

like image 12
sole007 Avatar answered Oct 24 '22 23:10

sole007