1.フォントサイズ指定
swift
---指定方法---
.font(フォントサイズ)
~~~~~~body内~~~~~~
VStack {
Group{
Text("largeTitle").font(.largeTitle)
Text("title").font(.title)
Text("title2").font(.title2)
Text("title3").font(.title3)
Text("headline").font(.headline)
Text("subheadline").font(.subheadline)
Text("body").font(.body)
}
Text("callout").font(.callout)
Text("caption").font(.caption)
Text("caption2").font(.caption2)
Text("footnote").font(.footnote)
Text("default")
}
2.フォントの太さ指定
swift
---指定方法---
.font(フォントの太さ)
~~~~~~body内~~~~~~
VStack {
Text("ultraLight").fontWeight(.ultraLight)
Text("thin").fontWeight(.thin)
Text("light").fontWeight(.light)
Text("regular").fontWeight(.regular)
Text("medium").fontWeight(.medium)
Text("semibold").fontWeight(.semibold)
Text("bold").fontWeight(.bold)
Text("heavy").fontWeight(.heavy)
Text("black").fontWeight(.black)
Text("default")
}.font(.title)
3.フォントタイプ指定
swift
---指定方法---
.font(.system(フォントサイズ, design: フォントタイプ))
フォントタイプ | 意味 |
---|---|
.default | 標準 |
.monospaced | 等幅 |
.rounded | 丸ゴシック体 |
.serif | 明朝体 |
4.フォントの装飾規定
swift
---指定方法---
.bold() 太字
.italic() 斜体
.underline(color: 色指定) 下線
5.フォント色指定
swift
---指定方法---
.foregroundColor(色指定)
例)
Text("Red").foregroundColor(.red)
Text("Blue").foregroundColor(.blue)
Text("Yellow").foregroundColor(.yellow)
Text("Green").foregroundColor(.green)
Text("Orange").foregroundColor(.orange)
Text("Pink").foregroundColor(.pink)
Text("Purple").foregroundColor(.purple)
Text("Black").foregroundColor(.black)
Text("Gray").foregroundColor(.gray)
6.フォントサイズの固定サイズ指定
swift
---指定方法---
.font(.system(size: サイズ, weight: フォントの太さ, design: フォントタイプ))
フォントサイズを指定した場合はどのデバイスでも変化しない固定サイズとなります。
7.カスタムフォント指定
swift
.font(.custom(フォント名, size: サイズ))