Swift playgrounds with UIImage

前端 未结 11 1865
轻奢々
轻奢々 2020-12-01 01:36

I am working with Xcode 6, and I\'m trying to recreate the code demoed during session 401 \"What\'s new in Xcode 6\". I\'ve added an image to Images.xcassets (called Sample)

11条回答
  •  [愿得一人]
    2020-12-01 02:12

    Using XCode 6.3.1 and running playground in full simulator (iOS) I had to do the following:

    1. Find your .playground file in finder
    2. Right click it -> show package contents
    3. If it doesn't already exist, create a folder named Resources inside the package
    4. Add your image there

    Then just instantiate with let i = UIImage(named: "filename.png")

提交回复
热议问题