如何更改 TextField 的文本大小和字段大小? [英] How do I change text size and field size of a TextField?

查看:43
本文介绍了如何更改 TextField 的文本大小和字段大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 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.

推荐答案

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

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)
    }

这篇关于如何更改 TextField 的文本大小和字段大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆