swiftui ios15 keyboard avoidance issue on custom textfield

Viewed 141

Repost question from this Adjust View up with Keyboard show in SwiftUI 3.0 iOS15.

SwiftUI keyboard avoidance won't show the whole textfield including the overlay.

I already tried a lot different ways from googling.
Does anyone have any solution for this?

struct ContentView: View {
    @State var text: String = ""
    var body: some View {
        ScrollView {
            VStack {
                Spacer(minLength: 600)
                TextField("Placeholder", text: $text)
                    .textFieldStyle(CustomTextFieldStyle())
            }
        }
    }
}

struct CustomTextFieldStyle: TextFieldStyle {
    func _body(configuration: TextField<Self._Label>) -> some View {
        configuration
            .padding(10)
            .overlay(
                RoundedRectangle(cornerRadius: 20)
                    .stroke(Color.red, lineWidth: 5)
            )
    }
}

Image Preview

0 Answers
Related