gpt4 book ai didi

ios - Swift 设置按钮图片

转载 作者:搜寻专家 更新时间:2023-11-01 06:52:59 24 4
gpt4 key购买 nike

当我尝试在按下按钮时更改按钮的图像,但它只显示一个蓝色方 block 作为按钮的图像

@IBAction func button(_ sender: Any) {
buttonOutlet.setImage(#imageLiteral(resourceName: "thing"), for: UIControl.State.normal)
}

最佳答案

来自 Apple 文档:

A control becomes highlighted when a touch event enters the control’s bounds...

Highlighted state of a control

button.setImage(UIImage(named: "button_normal_state"), for: .normal)
button.setImage(UIImage(named: "button_pressed_state"), for: .highlighted)

关于ios - Swift 设置按钮图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55888739/

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