- Learn Swift by Building Applications
- Emil Atanasov
- 146字
- 2021-06-25 22:13:51
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:
- Open the Navigator panel (cmd + 1)
- Select the Resources folder
- Press the + button at the bottom of the Navigator panel
- Select Add Files to 'Resources'...
- The file is automatically copied to the Resources folder
- 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
推薦閱讀
- C++程序設計教程
- 自然語言處理實戰:預訓練模型應用及其產品化
- LabVIEW2018中文版 虛擬儀器程序設計自學手冊
- Python網絡爬蟲從入門到實踐(第2版)
- Hadoop+Spark大數據分析實戰
- Hands-On JavaScript High Performance
- Mastering Yii
- Building Android UIs with Custom Views
- D3.js By Example
- Visual Studio 2015高級編程(第6版)
- SQL Server 2016 從入門到實戰(視頻教學版)
- 監控的藝術:云原生時代的監控框架
- ASP.NET Web API Security Essentials
- Ext JS 4 Plugin and Extension Development
- Mudbox 2013 Cookbook