Creating the Restaurant List screen
When using storyboards, you modify attributes of a view using the Attributes inspector. In SwiftUI, you can modify either your code or the preview on the canvas. As you have seen, changing the code in the ContentView.swift
file will immediately update the preview, and modifying the preview will update the code.
Let's customize the ContentView
structure to display the data of a particular restaurant. Follow these steps:
- Click the Library button. Type
tex
in the filter field, then drag a Text view to the canvas and drop it under the Lets Eat text: - Xcode has automatically added code to the
ContentView.swift
file for this text view. Verify that your code looks like this:struct ContentView: View { var body: some View { VStack{ ...