Using Swift Playgrounds for UI
Playgrounds are great for exploring the Swift language and the APIs available on Apple platforms, but they can also be very useful for experimenting with UI and testing custom views and interfaces. Let's build a very simple bar chart view that we can use to display numerical data in chart form, and use a playground to test it.
All the code for this chapter can be found in a GitHub repository at http://swiftbook.link/code/chapter6.
Getting ready
First, we'll create an iOS-based playground to build our bar chart. In Chapter 1, Swift Building Blocks, we went through creating a new playground, so go back there if you need a refresher.
We will create a custom view that will display information in bar chart form, and use that to test some features of playgrounds. You can either enter the following code into a new iOS-based playground or download the playground named Simple_iOS.playground
in the GitHub repository for this chapter:
import UIKit struct Color { let red:...