Uisearchbar is a search control that provides a text input box, a Find button, a bookmark button, and a Cancel button. We need to use the Uisearchbardelegate agent to find work;
Drag a Uisearchbar control
Properties in the right column
Text is the default, placeholder placeholder, which is the text that is displayed when the literal is not edited, and prompt is the text that appears on the box.
The above is the text to fill in the corresponding look
Continuation properties
These two properties are used to set the style:
Used to set the button;
The four buttons correspond to each other;
We can also set the background image:
respectively is
Above is used to set the background image, the following is used to set (check the fourth button above the scope bar) background picture
Let's take a look at the agent:uibarpositioningdelegate
Editing text–searchbar:textdidchange://Call –searchbar:shouldchangetextinrange:replacementtext://when search content changes This should be replaced with the last text range –searchbarshouldbeginediting://the search box in edit state –searchbartextdidbeginediting://when the user starts to edit the text- searchbarshouldendediting://the search box to end the editing state –searchbartextdidendediting://call clicking when the user finishes editing the text buttons– searchbarbookmarkbuttonclicked://called when the user taps the bookmark button –searchbarcancelbuttonclicked://when the user clicks the Cancel button – searchbarsearchbuttonclicked://called when the user clicks the Find button –searchbarresultslistbuttonclicked://the scope button– when the user clicks the results drop-down Results list button searchbar:selectedscopebuttonindexdidchange://called when the scope button changes
Commonly used proxy methods can be seen: Click to open the link
IOS Uisearchbar Learning Notes