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 in the canvas. As you have seen, changing the code in the ContentView
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 Selectable button in the canvas:
Fig 24.9: Canvas with Selectable button highlighted
This lets you drag and drop user interface elements from the Library into the canvas.
- Click the Library button. Type
tex
in the filter field, and drag a Text view to the canvas and drop it under the Lets Eat text:
Figure 24.10: Library with Text object to be dragged
- Xcode has automatically added code to the
ContentView
file for this text view. Verify that your...