---
title: "setBackgroundImage(_:for:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uinavigationbar/setbackgroundimage(_:for:)"
---

# setBackgroundImage(_:for:)

Sets the background image for given bar metrics.

## Declaration

```swift
func setBackgroundImage(_ backgroundImage: UIImage?, for barMetrics: UIBarMetrics)
```

## Parameters

- `backgroundImage`: The background image to use for barMetrics.
- `barMetrics`: A bar metrics constant.

## Discussion

Discussion Equivalent to using setBackgroundImage(_:for:barMetrics:) with a position of UIBarPosition.any.

## See Also

### Changing the background

- [barTintColor](uikit/uinavigationbar/bartintcolor.md)
- [backgroundImage(for:)](uikit/uinavigationbar/backgroundimage(for:).md)
- [backgroundImage(for:barMetrics:)](uikit/uinavigationbar/backgroundimage(for:barmetrics:).md)
- [setBackgroundImage(_:for:barMetrics:)](uikit/uinavigationbar/setbackgroundimage(_:for:barmetrics:).md)
