Я пытаюсь создать вид "чата", используя SwiftUI, и я хотел бы знать, как это сделать, чтобы динамически увеличивать высоту TextField, где пользователи должны писать свои сообщения.
I определили minHeight, ожидая, что TextField может увеличить свою высоту на основе своего внутреннего содержимого c.
Мой текущий код представления:
struct MessageSenderView: View {
@Binding var userTextInput: String
var body: some View {
VStack {
HStack(alignment: .center, spacing: 17) {
senderPlusImage()
ZStack {
Capsule()
.fill(Color("messagesBankDetailColor"))
.frame(minHeight: 34, alignment: .bottom)
HStack(spacing: 15){
Spacer()
ZStack(alignment: .leading) {
if userTextInput.isEmpty { Text(Constants.Login.Text.userPlaceHolder).foregroundColor(Color.white) }
TextField(" ", text: $userTextInput)
.multilineTextAlignment(.leading)
.frame(minHeight: CGFloat(34))
.foregroundColor(Color.white)
.background(Color("messagesBankDetailColor"))
.onAppear { self.userTextInput = "" }
}
arrowImage()
}
.frame(minHeight: CGFloat(34))
.padding(.trailing, 16)
.layoutPriority(100)
}
}
.padding(16)
}
.background(Color("mainBackgroundColor"))
}
}
И вот как это выглядит:

Спасибо !!!!