Create a view in a table
UIView *viewsearch=[[UIView alloc]initWithFrame:CGRectMake(0,-10, 320,83)]; [self.tblname addSubview:viewsearch]; [self.view addGestureRecognizer:revealController.panGestureRecognizer] UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0,5, 320, 40)]; searchBar.autoresizingMask = UIViewAutoresizingFlexibleWidth; searchBar.delegate=self; [searchBar setBarTintColor:[UIColor colorWithRed:(249/255.0) green:(9/255.0) blue:(99/255.0) alpha:1]]; searchBar.tintColor = [UIColor whiteColor]; searchBar.placeholder = @"Search items eg jacket";
Add a view to the search bar in this view.
[viewsearch addSubview:searchBar]
Use the UISegmentedControl in this search.
NSArray *itemArray = [NSArray arrayWithObjects: @"General", @"Near me", nil]; UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:itemArray]; segmentedControl.frame = CGRectMake(50,53, 225, 22); segmentedControl.segmentedControlStyle = UISegmentedControlStylePlain; [segmentedControl addTarget:self action:@selector(MySegmentControlAction:) forControlEvents: UIControlEventValueChanged]; segmentedControl.selectedSegmentIndex = 0; segmentedControl.tintColor = [UIColor colorWithRed:(249/255.0) green:(10/255.0) blue:(99/255.0) alpha:1]; segmentedControl.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin; [viewsearch addSubview:segmentedControl];
source share