Member-only story
How to Build a Multi-Line TextField in SwiftUI
Developed on Xcode 11.4 with SwiftUI
1 min readApr 4, 2020
As SwiftUI on iOS 13 does not support TextView
by default, we need to create our own UIViewRepresentable
. This UIViewRepresentable
can wrap TextView
which we can use in SwiftUI.
The UIViewRepresentable
protocol requires us to implement makeUIView
, updateUIView
, makeCoordinator
, UIViewType
, etc. So, now we shall try to create a UITextView
wrapper for SwiftUI.
Now that we are done creating the view, we need to set the coordinator delegate.
Recalculate the height and update the view in updateUIView
.