<!--
{
  "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/image(for:state:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UISearchBar(im)imageForSearchBarIcon:state:"
  },
  "title" : "image(for:state:)"
}
-->

# image(for:state:)

Returns the image for a given search bar icon type and control state.

```
func image(for icon: UISearchBar.Icon, state: UIControl.State) -> UIImage?
```

## Parameters

`icon`

An icon identifier constant.

`state`

A control state.

    Valid states are [`normal`](/documentation/UIKit/UIControl/State-swift.struct/normal)     and [`disabled`](/documentation/UIKit/UIControl/State-swift.struct/disabled)    .

## Return Value

The image used for the search bar icon identified by `icon` in the state identified by `state`.

## Discussion

---

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)