predicate Self.searchbar = [[Uisearchbar alloc]initwithframe:cgrectmake (0, Cgrectgetwidth (self.frame), 40)]; [Self addsubview:_searchbar];
Placeholder
[Self.searchbar setplaceholder:@ "Please enter"];
Color change
[Self.searchbar Setbarstyle:uibarstyleblackopaque];
Show right
[Self.searchbar Setshowsbookmarkbutton:yes];
Show right Cancel button
[Self.searchbar Setshowscancelbutton:yes Animated:yes];
Show search results [Self.searchbar setshowssearchresultsbutton:yes]; Proxy: 1. Introducing proxy @interface Rootviewcontroller () < Uisearchbardelegate>2. Set proxy-(void) Viewdidload {
[Super Viewdidload];
Do any additional setup after loading the view.
Self.rv.searchBar.delegate = self;} 3. Calling method-(void) searchbarcancelbuttonclicked: (Uisearchbar *) searchbar{
NSLog (@ "Cancel");} -(void) searchbarresultslistbuttonclicked: (Uisearchbar *) searchbar{
NSLog (@ "Search has been pressed");
NSLog (@ "%@", Searchbar.text);
}
-(BOOL) Searchbar: (Uisearchbar *) Searchbar Shouldchangetextinrange: (nsrange) Range Replacementtext: (NSString *) text{
NSLog (@ "start");
return YES;}
On-Attack UI----------------Uisearchbar (search box)