问题
I've spent hours trying to simply gain access to image data in my Swift Playground. I've followed many tutorials that recommend adding a resource folder as a sibling dir in the dir. your playground is in. Or to drag images into the Resources folder in the playground Navigator. Nothing has worked. What do I have to do to load an image view in playground?
回答1:
I solved this problem on my side when I
import PlaygroundSupport
- mark Resources Folder and tap + icon
- Choose Add files to 'Resources' and choose your image (here: image.png)
- Instance your image via
UIImage(named: "image.png")
Screenshot Xcode 9 Playground with UIImage
来源:https://stackoverflow.com/questions/45636060/how-to-load-an-image-into-an-xcode-9-playground