问题描述
我正在尝试为UIButton设置图像。
I am trying to set a image for a UIButton.
我不知道setBackgroundImage:Forstate和setImage之间的区别:Forstate:
I don't know the difference between the setBackgroundImage:Forstate and setImage:Forstate:
有人可以帮帮我吗?
谢谢和最好的问候。
推荐答案
-
setImage:forState:
将图像设置为按钮的实际内容。例如,即使您设置了按钮 title 也无法看到,因为您已将图像设置为内容。
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:
将图像设置为背景。在这种情况下,您可以设置标题,它会显示在图像的顶部。
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:Forstate和setImage之间有什么区别:Forstate:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!