Looked at a lot of information, not too full, I looked at the Apple document, wrote a code: The following (just interface):
1. Declare the attribute @property (nonatomic, strong) Uisearchcontroller *searchcontroller;
2. Calling method: [self searchcontroller];
3. Implementation:-(Uisearchcontroller *) Searchcontroller {
if (!_searchcontroller) {
_searchcontroller = [[Uisearchcontroller alloc] initwithsearchresultscontroller:nil];
Searchbar
_searchcontroller.searchbar.frame = CGRectMake (0, 0, kWidth-40, 36);
_searchcontroller.searchbar.placeholder = @ "Search";
_searchcontroller.searchbar.bartintcolor = [Uicolor colorwithred:1.00f green:0.62f blue:0.45f alpha:1.00f];
Searchbartextfield
Uitextfield *searchfield = nil;
Searchfield = [[_searchcontroller.searchbar.subviews objectatindex:0].subviews Lastobject];
Searchfield.backgroundcolor = [Uicolor colorwithred:1.00f green:0.62f blue:0.45f alpha:1.00f];
Uicolor *color = [Uicolor Whitecolor];
Searchfield.attributedplaceholder = [[Nsattributedstring alloc] initwithstring:@ "You can also enter keyword search" attributes:@{ Nsforegroundcolorattributename:color}];
_searchcontroller.view = [[UIView alloc] Initwithframe:cgrectmake (352/2, kWidth-40, 36)];
[_searchcontroller.view Addsubview:_searchcontroller.searchbar];
_searchcontroller.view.backgroundcolor = [Uicolor colorwithred:1.00f green:0.62f blue:0.45f alpha:1.00f];
[Self.tableheaderview AddSubview:self.searchController.view];
}
return _searchcontroller;
}
4. View the effect:
The usage of Uisearchcontroller after iOS8