-
Book Overview & Buying
-
Table Of Contents
SwiftUI Cookbook
By :
One of the most surprising and useful innovations brought by Swift is the Playground, a simple file that contains Swift code and that can be seen and modified in real time without waiting for a full cycle of a rebuild.
Again, Playground supports UIKit, but since SwiftUI can be quickly embedded in a UIKit component, we can use Playground for rapidly prototyping SwiftUI views too.
Create a Playground file (File | New | Playground) in Xcode called SwiftUIPlayground.
The power of Playground is that you can make a change and immediately see the result. Importing the PlaygroundSupport framework, you can also render a UIViewController class to be shown during the Playground session.
We are going to define a simple SwiftUI view to be rendered in Playground:
import PlaygroundSupport import SwiftUI
Text component...