ios – How to animate textField’s height grows in SwiftUI?


With below code, the textField grows when its line is increased and smaller than 5 lines. But there is no animation on textField’s height change, how could I apply an animation on that change?

struct TextClipView: View {
    @EnvironmentObject var textClipModel: TextClipModel
    private var placeholderString = "Type your text here!"
    
    var body: some View {
        GeometryReader { proxy in
            VStack(spacing: 20) {
                Spacer()
                    .frame(height: 80)
                
                TextField(placeholderString, text: $textClipModel.textClip, axis: .vertical)
                    .textFieldStyle(.roundedBorder)
                    .lineLimit(5)
                Spacer()
            }
            .frame(
                width: proxy.size.width,
                height: proxy.size.height
            )
        }
        .background(Color.green.opacity(0.2))
    }
}

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img