---
title: "backgroundImage(for:barMetrics:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uinavigationbar/backgroundimage(for:barmetrics:)"
---

# backgroundImage(for:barMetrics:)

Returns the background image to use for a given bar position and set of metrics.

## Declaration

```swift
func backgroundImage(for barPosition: UIBarPosition, barMetrics: UIBarMetrics) -> UIImage?
```

## Parameters

- `barPosition`: The location of the navigation bar.
- `barMetrics`: The metrics of the navigation bar.

## Return Value

Return Value The image to use for the specified location and metrics.

## Discussion

Discussion Resizable images will be stretched vertically, if necessary, for a position of UIBarPosition.topAttached.

## See Also

### Changing the background

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