无法将 UIImage 类型的值转换为预期的参数类型字符串



我对 swift 有一些问题。

Ground = SKSpriteNode(imageNamed: "#imageLiteral(resourceName: "Ground")")

这里说"无法将 UIImage 类型的值转换为预期的参数类型字符串"如何解决这个问题

我正在做:

profileImgView.image = UIImage(named: #imageLiteral(resourceName: "default_UserImage"))

虽然它应该是:

profileImgView.image = #imageLiteral(resourceName: "default_UserImage")

imageLiteral 已经返回 UIImage。

也许我错过了一些东西,但你为什么要添加这个?

#imageLiteral(resourceName: 

正确的语法是

let ground = SKSpriteNode(imageNamed: "Ground")

相关内容

最新更新