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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With