Using UIKit and SwiftUI Views together

At this point, you have learned how to create text views and image views for your app. Now let's see how to add a view that displays a map. When using storyboards, all you needed to do was to drag in a map view from the Object library to a view in storyboard. SwiftUI does not have a native map view but you can use the same map view that you used in storyboard to render the map. In fact, you can use any view subclass within SwiftUI by wrapping them in a SwiftUI view that conforms to the UIViewRepresentable protocol. You'll create a new custom view that can present a map view now. Do the following steps:

  1. Choose File | New | File to open the template selector.
  2. iOS should already be selected. In the User ...

Get iOS 13 Programming for Beginners - Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.