實例方法
truncation
truncationMode(_:)
為太長而無法放入可用空間的文本行設置截斷模式。
聲明
func truncationMode(_ mode: Text.TruncationMode) -> some View
返回值
根據您選擇的模式截斷一行中不同點處的文本的視圖。
參數
mode
截斷模式,指定在文本視圖中截斷文本的位置(如果需要)。您可以在文本視圖的開頭、中間或結尾截斷。
詳述
使用 truncationMode(_:)
修飾符確定長行中的文本是否在開頭、中間或結尾處被截斷。刪除文本時,通過在行中添加省略號 (...) 來指示截斷,以向讀者指示缺少文本。
在下麵的示例中,文本視圖的邊界限製了視圖顯示的文本量,truncationMode(_:)
指定從哪個方向以及在何處顯示截斷指示符:
Text("This is a block of text that will show up in a text element as multiple lines. The text will fill the available space, and then, eventually, be truncated.")
.frame(width: 150, height: 150)
.truncationMode(.tail)
可用版本
iOS 13.0+, iPadOS 13.0+, macOS 10.15+, Mac Catalyst 13.0+, tvOS 13.0+, watchOS 6.0+
相關用法
- Swift Optional transaction(_:)用法及代碼示例
- Swift Optional transformEffect(_:)用法及代碼示例
- Swift Optional textSelection(_:)用法及代碼示例
- Swift Optional toolbar(id:content:)用法及代碼示例
- Swift Optional tint(_:)用法及代碼示例
- Swift Optional toolbar(content:)用法及代碼示例
- Swift Optional tabItem(_:)用法及代碼示例
- Swift Optional textContentType(_:)用法及代碼示例
- Swift Optional touchBarItemPresence(_:)用法及代碼示例
- Swift Optional touchBar(_:)用法及代碼示例
- Swift Optional task(priority:_:)用法及代碼示例
- Swift Optional touchBar(content:)用法及代碼示例
- Swift Optional toggleStyle(_:)用法及代碼示例
- Swift Optional textInputAutocapitalization(_:)用法及代碼示例
- Swift Optional touchBarCustomizationLabel(_:)用法及代碼示例
- Swift Optional tag(_:)用法及代碼示例
- Swift Optional task(id:priority:_:)用法及代碼示例
- Swift Optional touchBarItemPrincipal(_:)用法及代碼示例
- Swift Optional symbolVariant(_:)用法及代碼示例
- Swift Optional popover(isPresented:attachmentAnchor:arrowEdge:content:)用法及代碼示例
- Swift Optional mask(alignment:_:)用法及代碼示例
- Swift Optional listSectionSeparatorTint(_:edges:)用法及代碼示例
- Swift Optional badge(_:)用法及代碼示例
- Swift Optional fullScreenCover(isPresented:onDismiss:content:)用法及代碼示例
- Swift Optional keyboardType(_:)用法及代碼示例
注:本文由純淨天空篩選整理自apple.com大神的英文原創作品 Optional truncationMode(_:)。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。