Skip to content
This repository was archived by the owner on Jan 19, 2025. It is now read-only.

Commit b5e3dd8

Browse files
committed
new post content ready 🚀
1 parent a4fc1b8 commit b5e3dd8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

_drafts/2020-06-08-expose-uikit-to-swiftui.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ struct DocumentPickerViewController: UIViewControllerRepresentable {
100100
}
101101
```
102102

103-
Now we are ready to use our controller...
103+
Now we are ready to use our UIKit controller and our custom UIView in a SwiftUI view. We can just add them to the `body` field of our view and use them as a standard SwiftUI component. One thing to be noted is the set of the `frame` on the `DocumentNameLabel` component. This is a consequence of the fact that sometimes the UIKit views wrapped with the `UIViewRepresentable` protocol take as much space as they can in a `VStack` component. This means that if we don't set the frame in our example the label would take the majority of the screen space (leaving only the space for button to be shown).
104104

105105
```swift
106106
struct ContentView: View {
@@ -130,3 +130,4 @@ struct ContentView: View {
130130

131131
#### Conclusion
132132

133+
`UIViewRepresentable` and `UIViewControllerRepresentable` are the tools provided by Apple to let you mix the power and versatility of UIKit with the declarative reactive approach of SwiftUI. I hope that in next future releases of the iOS SDK there will be no need to write this custom wrapper components at least for all the standard UIKit components.

0 commit comments

Comments
 (0)