UIHostingConfiguration
struct · iOS 16.0+ · SDK 27.1
struct UIHostingConfiguration<Content, Background> where Content : View, Background : ViewA content configuration suitable for hosting a hierarchy of SwiftUI views. Use a value of this type, which conforms to the <doc://com.apple.documentation/documentation/UIKit/UIContentConfiguration-9eib5> protocol, with a <doc://com.apple.documentation/documentation/UIKit/UICollectionViewCell> or <doc://com.apple.documentation/documentation/UIKit/UITableViewCell> to host a hierarchy of SwiftUI views in a collection or table view, respectively. For example, the following shows a stack with an image and text inside the cell: myCell.contentConfiguration = UIHostingConfiguration { HStack { Image(systemName: "star").foregroundStyle(.purple) Text("Favorites") Spacer() } } You can also customize the background of the containing cell. The following example draws a blue background: myCell.contentConfiguration = UIHostingConfiguration { HStack { Image(systemName: "star").foregroundStyle(.purple) Text("Favorites") Spacer() } } .background { Color.blue } When used in a list layout, certain APIs are bridged automatically, like swipe actions and separator alignment. The following example shows a trailing yellow star swipe action: cell.contentConfiguration = UIHostingConfiguration { HStack { Image(systemName: "airplane") Text("Flight 123") Spacer() } .swipeActions { Button { ... } label: { Label("Favorite", systemImage: "star") } .tint(.yellow) } }
Members (0)
This type has no directly callable members in this snapshot. See the framework’s skipped declarations for unsupported APIs.
Skipped declarations
2 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.
UIHostingConfiguration.background(content:)
callback cannot propagate synchronous failure
UIHostingConfiguration.init(content:)
callback cannot propagate synchronous failure