8

I'm trying to create an input similar like this (⬇) with SwiftUI.

enter image description here

I've made progress but I can't figure out how to change the height of the text fields and make the input text size bigger.

enter image description here

1 Answers1

20

You can change text size by changing the placeholder text's font size, which automatically adjusts the TextField's height.

In your case, this looks pretty similar to what you asked for:

HStack {
        Group {
            TextField($str, placeholder: Text("A"))
            TextField($str, placeholder: Text("B"))
            TextField($str, placeholder: Text("C"))
            TextField($str, placeholder: Text("D"))
        }
        .frame(width: 60, height: nil)
        .padding(.all, 5)
        .textFieldStyle(.roundedBorder)
        .font(Font.system(size: 60, design: .default))
        .multilineTextAlignment(.center)
    }
RPatel99
  • 7,448
  • 2
  • 37
  • 45