---
title: "setShowsCancelButton(_:animated:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uisearchbar/setshowscancelbutton(_:animated:)"
---

# setShowsCancelButton(_:animated:)

Sets the display state of the cancel button optionally with animation.

## Declaration

```swift
func setShowsCancelButton(_ showsCancelButton: Bool, animated: Bool)
```

## Parameters

- `showsCancelButton`: doc://com.apple.documentation/documentation/Swift/true to display the cancel button, otherwise doc://com.apple.documentation/documentation/Swift/false.
- `animated`: doc://com.apple.documentation/documentation/Swift/true to use animation to change the display state of the cancel button, otherwise doc://com.apple.documentation/documentation/Swift/false.

## Discussion

Discussion Cancel buttons are not displayed for apps running on iPad, even when you specify true for the showsCancelButton parameter

## See Also

### Configuring the search interface

- [showsBookmarkButton](uikit/uisearchbar/showsbookmarkbutton.md)
- [showsCancelButton](uikit/uisearchbar/showscancelbutton.md)
- [showsSearchResultsButton](uikit/uisearchbar/showssearchresultsbutton.md)
- [isSearchResultsButtonSelected](uikit/uisearchbar/issearchresultsbuttonselected.md)
