(_ alignment: TextAlignment) -> some View 返回值 對齊它包含的多行 Text 實例的行的視圖。參數 alignment 用於向左、向右或 center-align 視圖中的文本的值。詳述 使用multilineTextAlignment(_:) 選擇此視圖或視圖層次結構中所有文本的對齊方式。 在下麵的示例中,Text 視圖的內容居中對齊。這也適用於放...
var multilineTextAlignment: TextAlignment { get set } Discussion Set this value for a view hierarchy by applying the multilineTextAlignment(_:) view modifier. Views in the hierarchy that display text, like Text or TextEditor, read the value from the environment and adjust their text alignment...
当SwiftUI 的“Text” 视图跨多行换行时,默认情况下它们会对齐其前沿。 如果要更改此设置,请使用 multilineTextAlignment() 修饰符指定其他选项,例如 .center 或 .trailing。
multilineTextAlignment(_:) Instance Method Inherited fromView.multilineTextAlignment(_:). ArcGISSwiftUICoreiOS 13.0+iPadOS 13.0+Mac Catalyst 13.0+macOS 10.15+tvOS 13.0+watchOS 6.0+ nonisolatedfuncmultilineTextAlignment(_alignment:TextAlignment) ->someView...
self) { alignment in Text(String(describing: alignment)) } } Text("This is an extremely long text string that will never fit even the widest of phones without wrapping") .font(.largeTitle) .multilineTextAlignment(alignment) .frame(width: 300) } } }...
An environment value that indicates how a text view aligns its lines when the content wraps or contains newlines. iOS 13.0+ iPadOS 13.0+ macOS 10.15+ Mac Catalyst 13.0+ tvOS 13.0+ watchOS 6.0+ visionOS 1.0+ var multilineTextAlignment: TextAlignment { get set } ...
var multilineTextAlignment: TextAlignment { get set } Discussion Set this value for a view hierarchy by applying the multilineTextAlignment(_:) view modifier. Views in the hierarchy that display text, like Text or TextEditor, read the value from the environment and adjust their text alignment...
Text("This is a block of text that shows up in a text element as multiple lines.\("\n") Here we have chosen to center this text.") .frame(width: 200) .multilineTextAlignment(.center) The text in the above example spans more than one line because: The newline character introduces...
\("\n") Here we have chosen to center this text.") .frame(width: 200) .multilineTextAlignment(.center) The text in the above example spans more than one line because: The newline character introduces a line break. The frame modifier limits the space available to the text view, and...
An environment value that indicates how a text view aligns its lines when the content wraps or contains newlines. iOS 13.0+ iPadOS 13.0+ macOS 10.15+ Mac Catalyst 13.0+ tvOS 13.0+ watchOS 6.0+ visionOS 1.0+ var multilineTextAlignment: TextAlignment { get set } ...