A specialized view for receiving search-related information from the user.
SDKs
- iOS 2.0+
- Mac Catalyst 13.0+
- tvOS 9.0+
Framework
- UIKit
Declaration
class UISearchBar : UIView
Overview
UISearch
provides a text field for entering text, a search button, a bookmark button, and a cancel button. A search bar does not actually perform any searches. You use a delegate, an object conforming to the UISearch
protocol, to implement the actions when text is entered and buttons are clicked.
Customizing Appearance
You can customize the appearance of search bars one at a time, or you can use the appearance proxy ([UISearch
) to customize the appearance of all search bars in an app.
In general, you should specify a value for the normal state to be used by other states which don’t have a custom value set. Similarly, when a property is dependent on the bar metrics (on iPhone, in landscape orientation bars have a different height from standard), you should specify a value for UIBar
.