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

# searchBar

The search bar to install in your interface.

```
var searchBar: UISearchBar { get }
```

## Discussion

Before presenting your searchable content, install the search bar somewhere in your view hierarchy. The search bar becomes the starting point for searching your contents. Interactions with the search bar are handled automatically by the `UISearchController` object, which notifies the object in the [`searchResultsUpdater`](/documentation/UIKit/UISearchController/searchResultsUpdater) property whenever the search information changes.

You can provide a custom search bar by subclassing [`UISearchController`](/documentation/UIKit/UISearchController) and overriding this property to return your custom implementation. To ensure the correct configuration of your search bar, lazily initialize it when it’s first requested, as shown in the code below.

```objc
@implementation CustomSearchController {
    CustomSearchBar *customSearchBar;
}

// Override this property to return your custom implementation.
- (UISearchBar *)searchBar {
    // Lazily initialize your custom search bar.
    if (!customSearchBar) {
        customSearchBar = [[CustomSearchBar alloc] init];
    }
    return customSearchBar;
}

@end
```

---

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)