<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UISearchController/automaticallyShowsCancelButton",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UISearchController(py)automaticallyShowsCancelButton"
  },
  "title" : "automaticallyShowsCancelButton"
}
-->

# automaticallyShowsCancelButton

A Boolean indicating whether the search controller manages the visibility of the search bar’s cancel button.

```
var automaticallyShowsCancelButton: Bool { get set }
```

## Discussion

By default, [`UISearchController`](/documentation/UIKit/UISearchController) shows the search bar’s cancel button when search becomes active and hides it when the user dismisses search. You can take over responsibility for showing and hiding the cancel button by setting this property to <doc://com.apple.documentation/documentation/Swift/false>. If you set the search bar’s [`showsCancelButton`](/documentation/UIKit/UISearchBar/showsCancelButton) property, this property becomes <doc://com.apple.documentation/documentation/Swift/false>.

---

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)