setBackgroundImage:Forstate和setImage之间有什么区别:Forstate: [英] What's the difference between setBackgroundImage:Forstate and setImage:Forstate:

查看:148
本文介绍了setBackgroundImage:Forstate和setImage之间有什么区别:Forstate:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为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:

有人可以帮帮我吗?

谢谢和最好的问候。

推荐答案


  1. setImage:forState:将图像设置为按钮的实际内容。例如,即使您设置了按钮 title 也无法看到,因为您已将图像设置为内容。

  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.

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:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆