SwiftUI - TextField Example

Example of using a TextField in SwiftUI



import SwiftUI


struct ContentView: View {

    @State private var text: String = ""


    var body: some View {

        VStack {

            TextField("Enter your name", text: $text)

                .textFieldStyle(RoundedBorderTextFieldStyle())

                .padding()

            

        }

    }

}


struct ContentView_Previews: PreviewProvider {

    static var previews: some View {

        ContentView()

    }

}


Output :

SwiftUI - TextField Example SwiftUI - TextField Example Reviewed by KIRIT MODI on 22:56:00 Rating: 5

No comments:

Powered by Blogger.