<!--
{
  "availability" : [
    "iOS: 3.0.0 - 8.0.0",
    "iPadOS: 3.0.0 - 8.0.0",
    "macCatalyst: 13.1.0 - 13.1.0"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UISearchDisplayController/setActive(_:animated:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UISearchDisplayController(im)setActive:animated:"
  },
  "title" : "setActive(_:animated:)"
}
-->

# setActive(_:animated:)

Displays or hides the search interface, optionally with animation.

```
func setActive(_ visible: Bool, animated: Bool)
```

## Parameters

`visible`

<doc://com.apple.documentation/documentation/Swift/true> to display the search interface if it is not already displayed; <doc://com.apple.documentation/documentation/Swift/false> to hide the search interface if it is currently displayed.

`animated`

<doc://com.apple.documentation/documentation/Swift/true> to use animation for a change in visible state, otherwise <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

When the user focus in the search field of a managed search bar, the search display controller automatically displays the search interface. You can use this method to force the search interface to appear.

---

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)