Good day together,
I am currently trying to adjust the height of my TextEditor automatically. The whole thing should not increase further once 3 lines are reached.
The whole thing is modeled after the text field in the iMessage app.
Now to my problem: I'm trying to recreate the whole thing in SwiftUI and so far it works quite well, but I currently have the problem that the height of the control is not automatically adjusted and I unfortunately do not know how to do it best. Does anyone have a suggestion or even a solution for this?
SwiftUI Snippet:
VStack{
List{
}.listStyle(.plain)
HStack(alignment: .center){
Button{
}label:{
Image(systemName: "plus.circle")
.resizable()
.frame(width: 25, height: 25, alignment: .center)
}
HStack{
TextEditor(text: $message)
.focused($focusedField, equals: .messageView_TextEditor)
.foregroundColor(self.message == "Message" ? .gray : .primary)
.frame(height:35.0)
.onTapGesture {
if self.message == "Message"{
self.message = ""
}
}
.padding(.leading,10)
Button{
}label:{
Image(systemName: "arrow.up.circle.fill")
.resizable()
.frame(width: 25, height: 25, alignment: .center)
.padding(.trailing,5)
.foregroundColor(.green)
}
}.overlay(
RoundedRectangle(cornerRadius: 8)
.stroke(Color.gray, lineWidth: 1)
)
}
.padding(.bottom)
}