Swift 字体?->;一些观点。但为什么在siwftUI中添加修饰符时我们会这样使用:ext(";Hello,World!";).font(.body)?为什么要添加点'';?

Swift 字体?->;一些观点。但为什么在siwftUI中添加修饰符时我们会这样使用:ext(";Hello,World!";).font(.body)?为什么要添加点'';?,swift,swiftui,Swift,Swiftui,在Apple Developer文档中,字体修改器声明如下: func字体(\font:font?)->一些视图 但在SwiftUI中将其作为修饰符调用时,我们使用以下方式: Text(“你好,世界!”).font(.body) // ↑ //为什么要加这个点? 为什么我们要在正文前面加上那个点?声明 struct Font 系统在给定环境中使用字体时解析字体的值,因为字体是后期绑定标记 您可以通过字体静态属性获取标准字体 static le

在Apple Developer文档中,字体修改器声明如下:

func字体(\font:font?)->一些视图
但在SwiftUI中将其作为修饰符调用时,我们使用以下方式:

Text(“你好,世界!”).font(.body)
//                         ↑
//为什么要加这个点?
为什么我们要在
正文
前面加上那个点?

声明

struct Font
系统在给定环境中使用字体时解析字体的值,因为字体是后期绑定标记

您可以通过字体静态属性获取标准字体

static let largeTitle: Font
static let title: Font
static var headline: Font
static var subheadline: Font
static var body: Font
static var callout: Font
static var caption: Font
static var footnote: Font
书写

Text("some text").font(.title)

Text("some text").font(Font.title)
声明

struct Font
系统在给定环境中使用字体时解析字体的值,因为字体是后期绑定标记

您可以通过字体静态属性获取标准字体

static let largeTitle: Font
static let title: Font
static var headline: Font
static var subheadline: Font
static var body: Font
static var callout: Font
static var caption: Font
static var footnote: Font
书写

Text("some text").font(.title)

Text("some text").font(Font.title)

那么字体结构是这样的吗struct Font{static let largeTitle:Font static let title:Font static var headline:Font static var subheadline:Font static var body:Font static var callout:Font static var caption:Font static var footnote:Font}@sxlee要了解更多信息,请使用shift-ommand-0(或通过菜单窗口->开发者文档)n Xcode和search Font字体结构是这样的吗struct Font{static let largeTitle:Font static let title:Font static var headline:Font static var subheadline:Font static var body:Font static var callout:Font static var caption:Font static var footnote:Font}@sxlee要了解更多信息,请使用shift-ommand-0(或通过菜单窗口->开发者文档)n Xcode和搜索FontHi!我建议你重新表述你的问题,你问的不是很清楚。嗨!我建议你重新表述你的问题,你问的不是很清楚。