One Logo Pool Ball
SwiftUI · IOS API REFERENCE

TableColumnCustomization

struct · iOS 17.0+ · SDK 27.1

struct TableColumnCustomization<RowValue> where RowValue : Identifiable

A representation of the state of the columns in a table. `TableColumnCustomization` can be created and provided to a table to enable column reordering and column visibility. The state can be queried and updated programmatically, as well as bound to persistent app or scene storage. struct BugReportTable: View { @ObservedObject var dataModel: DataModel @Binding var selectedBugReports: Set<BugReport.ID> @SceneStorage("BugReportTableConfig") private var columnCustomization: TableColumnCustomization<BugReport> var body: some View { Table(dataModel.bugReports, selection: $selectedBugReports, sortOrder: $dataModel.sortOrder, columnCustomization: $columnCustomization ) { TableColumn("Title", value: \.title) .customizationID("title") TableColumn("ID", value: \.id) { Link("\($0.id)", destination: $0.url) } .customizationID("id") TableColumn("Number of Reports", value: \.duplicateCount) { Text($0.duplicateCount, format: .number) } .customizationID("duplicates") } } } The above example creates a table with three columns. On macOS, these columns can be reordered or hidden and shown by the user of the app. Their configuration will be saved and restored with the window on relaunches of the app, using the "BugReportTableConfig" scene storage identifier. The state of a specific column is stored relative to its customization identifier, using using the value from the ``TableColumnContent/customizationID(_:)`` modifier. When column customization is encoded and decoded, it relies on stable identifiers to restore the associate the saved state with a specific column. If a table column does not have a customization identifier, it will not be customizable. These identifiers can also be used to programmatically change column customizations, such as programmatically hiding a column: columnCustomization[visibility: "duplicates"] = .hidden With a binding to the overall customization, a binding to the visibility of a column can be accessed using the same subscript syntax: struct BugReportTable: View { @SceneStorage("BugReportTableConfig") private var columnCustomization: TableColumnCustomization<BugReport> var body: some View { ... MyVisibilityView($columnCustomization[visibility: "duplicates"]) } } struct MyVisibilityView: View { @Binding var visibility: Visibility ... }

Members (0)

This type has no directly callable members in this snapshot. See the framework’s skipped declarations for unsupported APIs.

Skipped declarations

1 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

TableColumnCustomization.init()

The containing type needs Swift generic type arguments. (no canonical witness for RowValue)

All SwiftUI types →