How do I change text size and field size of a TextField?

Nat*_*cks 3 ios swift swiftui

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

在此处输入图片说明

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.

在此处输入图片说明

RPa*_*l99 8

您可以通过更改占位符文本的字体大小来更改文本大小,该占位符文本会自动调整TextField的高度。

在您的情况下,这看起来与您要求的内容非常相似:

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)
    }
Run Code Online (Sandbox Code Playgroud)