官术网_书友最值得收藏!

How to add resource to a playground

Follow these steps to add an image to your playground. Try to use a .png or .jpg—images look great once you load them in a playground:

  1. Open the Navigator panel (cmd + 1)
  2. Select the Resources folder
  3. Press the + button at the bottom of the Navigator panel
  1.  Select Add Files to 'Resources'...
  2. The file is automatically copied to the Resources folder
  3. Try to use it in the main playground

For example, to use an image in the iOS playground you can use the following code:

let img = UIImage(named: "open_xcode.png")

Where the name of the file is open_xcode.png. Don't worry about the code and what UIImage means. We will understand this a bit later on in the book. Take a look at the following screenshot:

Adding an image to your playground

主站蜘蛛池模板: 秦安县| 和林格尔县| 天门市| 南召县| 特克斯县| 延川县| 曲麻莱县| 翁源县| 甘谷县| 特克斯县| 开封县| 永昌县| 罗甸县| 旺苍县| 五指山市| 牟定县| 哈巴河县| 霍林郭勒市| 新晃| 上蔡县| 禄丰县| 启东市| 清苑县| 双柏县| 开化县| 应用必备| 虎林市| 定兴县| 西林县| 克山县| 罗江县| 台中市| 明水县| 浑源县| 山阴县| 余干县| 巴彦县| 友谊县| 景泰县| 紫阳县| 赣榆县|