Uisearchbar inherit from UIView, Uiresponder, NSObject
Uisearchbar Property settings
Code
1-(void) Createsearchbar2 {3_searchbar = [[Uisearchbar alloc] Initwithframe:cgrectmake (0,0, [UIScreen Mainscreen].bounds.size.width, +)];4 //Setting Control Styles5_searchbar.barstyle =uisearchbarstyleprominent;6 7 //Automatic Case setting of text objects8 //contains four types of9 /*Ten typedef ns_enum (Nsinteger, uitextautocapitalizationtype) { One Uitextautocapitalizationtypenone, A Uitextautocapitalizationtypewords, - Uitextautocapitalizationtypesentences, - Uitextautocapitalizationtypeallcharacters, the }; - */ -_searchbar.autocapitalizationtype =Uitextautocapitalizationtypenone; - + //automatic error correction of input text - //altogether three kinds + /* A typedef ns_enum (Nsinteger, uitextautocorrectiontype) { at Uitextautocorrectiontypedefault, - Uitextautocorrectiontypeno, - Uitextautocorrectiontypeyes, - } - */ -_searchbar.autocorrectiontype =Uitextautocorrectiontypedefault; in - //Control background picture to_searchbar.backgroundimage = [UIImage imagenamed:@""]; + - //The right side of the control displays a Cancel button displayed by default the_searchbar.showscancelbutton =YES; * $ //displays a search results button at the right end of the controlPanax Notoginseng_searchbar.showssearchresultsbutton =YES; - the //whether the search results button is selected +_searchbar.searchresultsbuttonselected =NO; A the //a button on the right side of the control that displays a book disappears when you enter text +_searchbar.showsbookmarkbutton =YES; - $ //text displayed above the control $ //_searchbar.text = @ "2"; - - //set whether a control has a pivot effect the_searchbar.translucent =NO; - Wuyi //Set placeholder text (hint text) to disappear when you enter text the_searchbar.placeholder =@"Please enter text"; - Wu //Set the keyboard style when typing -_searchbar.keyboardtype =Uikeyboardtypenumberpad; About $ //set a line of prompt text that appears at the top of the control -_searchbar.prompt =@"I am Searchbar"; - - //set the color of bar A_searchbar.tintcolor =[Uicolor Greencolor]; + //set up proxy <UISearchBarDelegate> the_searchbar.Delegate=Self ; - $ //The contents of the selection bar array below the search bar are the caption of the button the //_searchbar.scopebuttontitles; the the //The number of selection bar buttons below the search bar the_searchbar.selectedscopebuttonindex =3; - in //whether to display the selection bar below the search bar needs to be set to Yes to use Scopebar the_searchbar.showsscopebar =YES; the AboutSelf.navigationItem.titleView =_searchbar; the}
Uisearchbar does not perform search behavior, you must use delegate, and when you enter search text, click a button, or gesture, the proxy method completes the search action.
Not to be continued
IOS UI Learning Uisearchbar