SwiftUI and UIKit “talk” by UIViewRepresentable

Goal栈
5 min readJun 5, 2020

OK, as the title side, when you are trying to start embed SwiftUI into your exist project, you may facing to use UIKit in SwiftUI.

In your project, you made a gorgeous customised UIView, and you just want to use it directly in SwiftUI. How?

By UIViewRepresentable .

Background

You have the most beautiful text field like below:


class
CurrencyTextField: UITextField {
xxx
}

--

--