Djselectcityviewcontroller.m
/** Searchbar start editing*/- (void) Searchbartextdidbeginediting: (Uisearchbar *) Searchbar {//Hide Navigation bar[Self.navigationcontroller Setnavigationbarhidden:yes Animated:yes]; //Show MatteUIView *cover =[[UIView alloc] init]; Cover.backgroundcolor=[Uicolor Blackcolor]; Cover.alpha=0.2; Cover.frame=Self.cityTableView.frame; Cover.tag=Djcovertag; //since UIView is not uicontrol, there is no Addtarget method, you can use UITapGestureRecognizer instead//Remove the first responder when Conver is clicked[cover Addgesturerecognizer:[[uitapgesturerecognizer alloc] initwithtarget:searchbar action: @selector ( Resignfirstresponder)]; [Self.view addsubview:cover];}/** Searchbar End Edit*/- (void) Searchbartextdidendediting: (Uisearchbar *) Searchbar {//Show navigation bar[Self.navigationcontroller setnavigationbarhidden:no Animated:yes]; //Hide Masks[[Self.view Viewwithtag:djcovertag] removefromsuperview]; }
Final effect:
Group HD (6)-Add search Matte