<!--
{
  "availability" : [
    "iOS: 7.0.0 -",
    "iPadOS: 7.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UINavigationBar/setBackgroundImage(_:for:barMetrics:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UINavigationBar(im)setBackgroundImage:forBarPosition:barMetrics:"
  },
  "title" : "setBackgroundImage(_:for:barMetrics:)"
}
-->

# setBackgroundImage(_:for:barMetrics:)

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

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

## Parameters

`backgroundImage`

The image to use for the specified location and metrics.

`barPosition`

The location of the navigation bar.

`barMetrics`

The metrics of the navigation bar.

## Discussion

Resizable images will be stretched vertically, if necessary, for a position of [`UIBarPosition.topAttached`](/documentation/UIKit/UIBarPosition/topAttached).

---

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)