32.6 Wrapping the UIScrolledView
The first step in the project is to use the UIViewRepresentable protocol to wrap the UIScrollView so that it can be used with SwiftUI. Right-click on the UIViewDemo entry in the project navigator panel, select the New File… menu option and create a new file named MyScrollView using the SwiftUI View template.
With the new file loaded into the editor, delete the current content and modify it so it reads as follows:
import SwiftUI
struct MyScrollView: UIViewRepresentable {
var text: String
func makeUIView(context: UIViewRepresentableContext<MyScrollView>)
-> UIScrollView {
let scrollView = UIScrollView()
scrollView.refreshControl = UIRefreshControl()
...