How to set the cursor to end of the TextField? SwiftUI

1.6k Views Asked by At

I want to set the cursor to the end of the TextField like this image1

This is want I have image2

Can anyone give advice?

1

There are 1 best solutions below

2
ChrisR On BEST ANSWER

only this time :)

    Form {
        HStack {
            Text("User Name")
            TextField("user",text: $user)
                .multilineTextAlignment(.trailing)
        }
        HStack {
            Text("Password")
            TextField("password",text: $password)
                .multilineTextAlignment(.trailing)
        }
    }