實例方法
list
listRowInsets(_:)
對列表中的行應用插圖。
聲明
func listRowInsets(_ insets: EdgeInsets?) -> some View
返回值
用作列表單元格時使用給定邊插圖的視圖。
參數
insets
EdgeInsets
應用於視圖的邊。
詳述
使用 listRowInsets(_:)
更改列表項內容的默認填充。
在下麵的示例中,Flavor
枚舉為列表項提供內容。 SwiftUI ForEach
結構計算Flavor
枚舉的每個元素的視圖,並使用結果文本提取其每個元素的原始值以創建每個列表行項目。 listRowInsets(_:)
修飾符然後根據提供的EdgeInsets
更改列表中每一行的邊插入:
struct ContentView: View {
enum Flavor: String, CaseIterable, Identifiable {
var id: String { self.rawValue }
case vanilla, chocolate, strawberry
}
var body: some View {
List {
ForEach(Flavor.allCases) {
Text($0.rawValue)
.listRowInsets(.init(top: 0,
leading: 25,
bottom: 0,
trailing: 0))
}
}
}
}
可用版本
iOS 13.0+, iPadOS 13.0+, macOS 10.15+, Mac Catalyst 13.0+, tvOS 13.0+, watchOS 6.0+
相關用法
- Swift Optional listRowSeparator(_:edges:)用法及代碼示例
- Swift Optional listRowSeparatorTint(_:edges:)用法及代碼示例
- Swift Optional listRowBackground(_:)用法及代碼示例
- Swift Optional listSectionSeparatorTint(_:edges:)用法及代碼示例
- Swift Optional listSectionSeparator(_:edges:)用法及代碼示例
- Swift Optional lineSpacing(_:)用法及代碼示例
- Swift Optional lineLimit(_:)用法及代碼示例
- Swift Optional luminanceToAlpha()用法及代碼示例
- Swift Optional labelsHidden()用法及代碼示例
- Swift Optional labelStyle(_:)用法及代碼示例
- Swift Optional layoutPriority(_:)用法及代碼示例
- Swift Optional symbolVariant(_:)用法及代碼示例
- Swift Optional popover(isPresented:attachmentAnchor:arrowEdge:content:)用法及代碼示例
- Swift Optional mask(alignment:_:)用法及代碼示例
- Swift Optional badge(_:)用法及代碼示例
- Swift Optional fullScreenCover(isPresented:onDismiss:content:)用法及代碼示例
- Swift Optional keyboardType(_:)用法及代碼示例
- Swift Optional clipShape(_:style:)用法及代碼示例
- Swift Optional preferredColorScheme(_:)用法及代碼示例
- Swift Optional background(_:ignoresSafeAreaEdges:)用法及代碼示例
- Swift Optional saturation(_:)用法及代碼示例
- Swift Optional focusSection()用法及代碼示例
- Swift Optional overlay(alignment:content:)用法及代碼示例
- Swift Optional colorMultiply(_:)用法及代碼示例
- Swift Optional confirmationDialog(_:isPresented:titleVisibility:presenting:actions:message:)用法及代碼示例
注:本文由純淨天空篩選整理自apple.com大神的英文原創作品 Optional listRowInsets(_:)。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。