UIButton的图像显得微弱?

时间:2017-05-24 16:53:19

标签: ios uibutton

我试图将UIButton's图片更改为白色,并在按下时将其设置为背景颜色,以此结束:

image

我将按钮的图像设置为白色并将其设置为背景颜色,如下所示:

button.setImage(UIImage(named: "Food_White")?.withRenderingMode(.alwaysOriginal), for: .highlighted)
button.setBackgroundImage(UIImage.imageWithColor(UIColor.gray, size: CGSize(width: 1.0, height: 1.0)), for: .highlighted)

但是当我按下按钮时,白色图像几乎不显示:

button

有人知道如何让图像变得微弱吗?

1 个答案:

答案 0 :(得分:1)

创建它们时是否使用默认按钮类型?

尝试使用.custom类型而非默认.system

创建按钮
相关问题