I want to handle each TextField
in ForEach
. Here is the screen, when I type c in one field, all other fields will also have c written in them.
The Code:
VStack {
HStack {
Spacer()
ForEach(0..<word.word.letters.count, id: \.self) { _ in
VStack {
TextField("", text: $data.textfieldLetter)
.frame(width: 20, alignment: .center)
.foregroundColor(.white1)
.padding(.leading, .padding1)
RoundedRectangle(cornerRadius: 15)
.frame(width: 20, height: 10, alignment: .center)
.foregroundColor(.black)
}
}
Spacer()
}
.frame(width: UIScreen.main.bounds.size.width / 1.10, height: 15)
.fixedSize(horizontal: true, vertical: false)
}
The textfield count is dynamically changed by the description of word. How can i manage each textfield like otp textfield?
Single value