---
title: "scopeBarButtonBackgroundImage(for:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uisearchbar/scopebarbuttonbackgroundimage(for:)"
---

# scopeBarButtonBackgroundImage(for:)

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

## Declaration

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

## Parameters

- `state`: A control state.

## Return Value

Return Value The background image for the scope bar button in state.

## Discussion

Discussion If the background image is an image returned from 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.

## See Also

### Customizing the scope bar appearance

- [scopeBarBackgroundImage](uikit/uisearchbar/scopebarbackgroundimage.md)
- [setScopeBarButtonBackgroundImage(_:for:)](uikit/uisearchbar/setscopebarbuttonbackgroundimage(_:for:).md)
- [scopeBarButtonDividerImage(forLeftSegmentState:rightSegmentState:)](uikit/uisearchbar/scopebarbuttondividerimage(forleftsegmentstate:rightsegmentstate:).md)
- [setScopeBarButtonDividerImage(_:forLeftSegmentState:rightSegmentState:)](uikit/uisearchbar/setscopebarbuttondividerimage(_:forleftsegmentstate:rightsegmentstate:).md)
- [scopeBarButtonTitleTextAttributes(for:)](uikit/uisearchbar/scopebarbuttontitletextattributes(for:).md)
- [setScopeBarButtonTitleTextAttributes(_:for:)](uikit/uisearchbar/setscopebarbuttontitletextattributes(_:for:).md)
