- 字体粗细
可以通过在Text视图中设置.font属性来实现字体粗细的调整。例如,您可以使用.font(.bold())来使文本视图的字体加粗。
例如:
Text("Hello, SwiftUI!")
.font(.bold())
- 文本颜色
可以通过在Text视图中设置.foregroundColor属性来实现文本颜色的调整。例如,您可以使用.foregroundColor(.red)来使文本视图的颜色变为红色。
例如:
Text("Hello, SwiftUI!")
.foregroundColor(.red)
- 多行文本
可以通过在Text视图中使用.multilineTextAlignment(.center)属性来实现多行文本的调整。例如,您可以使用.multilineTextAlignment(.center)来使文本视图中的文本在中心对齐。
例如:
Text("Hello, SwiftUI!\nThis is a multiline text example.") .multilineTextAlignment(.center)
- 对齐
可以通过在Text视图中使用.textAlignment(.right)属性来实现对齐的调整。例如,您可以使用.textAlignment(.right)来使文本视图中的文本向右对齐。
例如:
Text("Hello, SwiftUI!")
.font(.bold())
.foregroundColor(.red)
.multilineTextAlignment(.center)
.padding()