Maric Vikike
Maric Vikike

Reputation: 247

How can I use image inside Xcode 11 playground?

I am doing the SwiftUI tutorial which is on the Apple's website in Xcode 11 playground because I use Mojave and not Catalina. There is an image called turtlerock.jpg, but it doesn't show in the playground.

I put the image inside the resource folder, but no luck.

Upvotes: 8

Views: 2403

Answers (1)

David Ackerman
David Ackerman

Reputation: 492

I've been scratching my head over this problem too. I've managed to find at least a workaround for now:

Instead of:

Image("turtlerock")

try:

Image(uiImage: UIImage(named: "turtlerock.jpg")!)

You'll have to have turtlerock.jpg in the Resources folder of your playground. If you turn it into a .png first, you can use UIImage(named: "turtlerock") in the above.

Upvotes: 21

Related Questions