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

前端 未结 3 1939
花落未央
花落未央 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条回答
  •  感动是毒
    2021-01-04 01:53

    The difference is in the framing

    I will explain you with the help of example suppose your image size is 40*40 and button frame is 20*20 then if you use setBackgroundImage:forState: method the image will be displayed in 20*20 frame and if you use setImage:forState: method you will see a button with image size of 40*40 frame. This is the difference.

    Happy Coding!!

提交回复
热议问题