<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/UIHostingConfiguration/background(content:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI22UIHostingConfigurationV10background7contentACyxqd__Gqd__yXE_tAA4ViewRd__lF"
  },
  "title" : "background(content:)"
}
-->

# background(content:)

Sets the background contents for the hosting configuration’s enclosing
cell.

```
func background<B>(@ContentBuilder content: () -> B) -> UIHostingConfiguration<Content, B> where B : View
```

## Parameters

`content`

The contents of the SwiftUI hierarchy to be
shown inside the background of the cell.

## Discussion

The following example sets a custom view to the background of the cell:

```
UIHostingConfiguration {
    Text("My Contents")
}
.background {
    MyBackgroundView()
}
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)