Using UIKit and SwiftUI Views together
At this point, you have created the Restaurant List screen, and tapping each cell in this screen displays the restaurant's name on a second screen. You'll modify your app to display a Restaurant Detail screen when a cell on the Restaurant List screen is tapped, but before that, you'll create a SwiftUI view that displays a map.
When using storyboards, all you needed to do was to drag in a map view from the Library to a view in the storyboard. SwiftUI does not have a native map view but you can use the same map view that you used in the storyboard to render the map. In fact, you can use any view subclass in SwiftUI by wrapping them in a SwiftUI view that conforms to the UIViewRepresentable
protocol. Let's create a custom view that can present a map view now. Follow these steps:
- Choose File | New | File to open the template selector.
- iOS should already be selected. In the User Interface section, click SwiftUI View...