swift - 更改 NSButton 的图像

标签 swift macos

我试图更改按钮的背景图像,但它给了我这个错误:

Value of type '(NSButton) -> ()' has no member 'image'

likeButton.image = NSImage(named: NSImage.Name("like"))

最佳答案

您可以使用setBackgroundImage函数来更改它。

例如

likeButton.setBackgroundImage(anImage, for: UIControl.State.normal)

关于swift - 更改 NSButton 的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58581466/

相关文章:

ios - 如果 TextField 为空,则禁用按钮

ios - Firebase Swift childByAutoId()

ios - 更新段中的行数以进行段控制选择

macos - 从 Mac OSX 访问 Centos Apache 服务器(在 Parallels 10 中托管)

macos - dnsmasq - Apple Silicon M1 上的服务状态问题

macos - selfupdate macports 不工作

javascript - 如何在 ESLint 中设置 jQuery?

macos - 获取包含要执行的管道的 zsh 别名

swift - 根据Model更新UIButton的图像

ios - Coredata 中的关系错误