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

前端 未结 3 1930
花落未央
花落未央 2021-01-04 01:18

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 o

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-04 01:56

    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.

提交回复
热议问题