SwiftUI text-alignment

后端 未结 9 1515
逝去的感伤
逝去的感伤 2020-12-29 00:42

Among the many properties of the Text view, I couldn\'t find any related to text alignment. I\'ve seen in a demo that it automatically handles RTL, and when pla

9条回答
  •  悲&欢浪女
    2020-12-29 01:13

    I've actually run into the problem where I had to align text on a single line. What I've found to work is this:

    Text("some text")
        .frame(alignment: .leading)
    

    If you combine this with the frame width parameter you can get some nice text block formatting for labels and such.

提交回复
热议问题