🔸no wrap

╱🚧 under construction ->

SwiftUIcontrolsTextformat ⟩ no wrap

文字不折行顯示。

// text: no wrap
Text("It's a long long story ...")
    .fixedSize()            // ⭐️ 將文字限制在它原有的尺寸(不動態調整)

// 下面的做法雖然類似,但因為文字會被省略 (就算不指定 .truncationMode 也是如此)
// 因此效果通常不理想。
Text("It's a long long story ...")
    .lineLimit(1)           // 限制行數為 1
    .truncationMode(.tail)  // 使用省略號顯示超出部分(可選 .head, .middle, .tail)

Last updated

Was this helpful?