はじめに
Textの行間スペースを調整するという内容です。
どこのことだ?と思うかたもいると思うので画像で説明します。
改行された文と文の間のスペースを本記事では行間スペースと表現しています。
サンプルアプリ
サンプルアプリの実装
import SwiftUI
struct ContentView: View {
@State private var lineSpacing: CGFloat = 0.0
var body: some View {
VStack {
Text("""
あああああああああああああああああ
あああああああああああああああああ
あああああああああああああああああ
あああああああああああああああああ
""")
+ .lineSpacing(lineSpacing)
Stepper(value: $lineSpacing) {
Text("lineSpacing: \(lineSpacing)")
}
}
.padding(20)
}
}
おわり
Textのheightを小さくしたいときに使えそうですね
公式ドキュメント