gpt4 book ai didi

ios - UIButton 的图像显示模糊?

转载 作者:行者123 更新时间:2023-11-29 00:21:24 24 4
gpt4 key购买 nike

我正在尝试将 UIButton 的 图像更改为白色,并在按下时设置背景颜色,最终得到如下结果:

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

有人知道如何使图像不那么模糊吗?

最佳答案

您在创建按钮时是否使用默认按钮类型?

尝试使用 .custom 类型而不是默认的 .system 创建按钮

关于ios - UIButton 的图像显示模糊?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44164408/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com