点击UISearchBarDisplayController中的SearchBar,navigationBar上移推出屏幕,searchBar上移至原navigationBar位置;在点击“取消”按钮,回复原状态。如图
UISearchBar *searchBar = [[UISearchBaralloc]initWithFrame:CGRectMake(0,0,320,44)];
searchBar.delegate =self;
searchBar.showsCancelButton =NO;
[self.viewaddSubview: searchBar];
UISearchDisplayController *searchDisplayController = [[UISearchDisplayControlleralloc]initWithSearchBar:_searchBarcontentsController: self];
[searchDisplayControllersetDelegate: self];
searchDisplayController.searchBar.tintColor = [UIColorcolorWithRed: 0.8green:0.8blue:0.8 alpha:1.0];
[searchDisplayController.searchBarsetScopeButtonTitles:[NSArrayarrayWithObjects: @"搜视频",@"搜人",nil]];
[searchBarrelease];
[searchDisplayControllerrelease];