首页 > 解决方案 > SwiftUI 标题字体

问题描述

我正在尝试找到一种获取List' 标题的系统字体的好方法。这就是我的意思:

struct ContentView: View {
    var body: some View {
        List {
            Section(header: Text("Test")) {
                Text("Blablabla")
            }
        }
    }
}

在此处输入图像描述

基本上,有没有办法以编程方式获取图像中显示“测试”的文本的字体,所以我可以在Text对象的其他地方使用它?

我是尝试通过使用来制作可折叠标题DisclosureGroup的字体,但是 的字体DisclosureGroupSection.

标签: swiftswiftui

解决方案


另一种方法是给出你想要的字体,然后在你想要的任何地方使用它,很有趣:

Text("Test").font(.largeTitle)

Text("Test").font(.system(size:34))

Text("Test").font(.system(size: 20, weight: .bold, design: .serif)))

Text("Test").font(Font.custom("Wingdings", size: 30.0))

Text("Test").font(Font.custom("Montserrat-Bold", size: 30.0))

推荐阅读