If you want to create a chat feature with messages that take up multiple lines, this project might be useful for you.
SwiftUI doesn’t have a built-in text box like UITextView, so you need to create a custom one.
Also, UITextView doesn’t support placeholders. This component solves both problems by allowing placeholders and
automatically expanding up to a set height.
- Custom
TextViewWrapperto integrateUITextViewinto SwiftUI. MultilineTextInputViewthat supports placeholders and dynamic height adjustment.ChatViewto display messages in a chat-like interface.
- TextViewWrapper: A
UIViewRepresentablethat wrapsUITextViewfor use in SwiftUI. - MultilineTextInputView: A SwiftUI view that uses
TextViewWrapperto provide a text input field with placeholder support and dynamic height adjustment. - ChatView: A SwiftUI view that displays a list of messages and includes the
MultilineTextInputViewfor message input.
Ensure that you have the necessary components (TextViewWrapper, MultilineTextInputView, and ChatView) included in your project.
This project is inspired by the need to implement multiline text input in SwiftUI and aims to provide a reusable solution for the community.
