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

# scopeBarButtonBackgroundImage(for:)

Returns the background image for the scope bar button in a given state.

```
func scopeBarButtonBackgroundImage(for state: UIControl.State) -> UIImage?
```

## Parameters

`state`

A control state.

## Return Value

The background image for the scope bar button in `state`.

## Discussion

If the background image is an image returned from [`stretchableImage(withLeftCapWidth:topCapHeight:)`](/documentation/UIKit/UIImage/stretchableImage(withLeftCapWidth:topCapHeight:)) (`UIImage`), the cap widths are calculated from that information, otherwise, the cap width is calculated by subtracting one from the image’s width then dividing by 2. The cap widths are used as the margins for text placement. To adjust the margin use the margin adjustment methods.

---

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)