See the code
-(IBAction)simple_picker:(id)sender{
pickerViewPopup = [[UIActionSheet alloc] init];
const CGFloat toolbarHeight = 44.0f;
Picker = [[UIPickerView alloc] initWithFrame:CGRectMake(0, toolbarHeight, 0, 0)];
Picker.showsSelectionIndicator = YES;
Picker.dataSource = self;
Picker.delegate = self;
//........
UIToolbar *pickerToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, toolbarHeight)];
pickerToolbar.barStyle = UIBarStyleBlackOpaque;
[pickerToolbar sizeToFit];
NSMutableArray *barItems = [[NSMutableArray alloc] init];
UIBarButtonItem *cancel= [[UIBarButtonItem alloc]initWithTitle:@"Cancel" style:UIBarButtonItemStyleBordered target:self action:@selector(Cancel_picker:)];
[barItems addObject:cancel];
UIBarButtonItem *flexSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
[barItems addObject:flexSpace];
//....
UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(doneButtonPressed2:)];
[barItems addObject:doneBtn];
[pickerToolbar setItems:barItems animated:YES];
[pickerViewPopup addSubview:pickerToolbar];
lbl2.text=[picArray objectAtIndex:0];
[pickerViewPopup addSubview:Picker];
[pickerViewPopup showInView:self.view.superview];
[pickerViewPopup setBounds:CGRectMake(0,0,self.view.frame.size.width, 464)];
}
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView;
{
return 1;
}
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
lbl2.text= [picArray objectAtIndex:row];
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component;
{
return [picArray count];
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component;
{
return [picArray objectAtIndex:row];
}
-(void)btncancelPressed2:(id)sender{
[pickerViewPopup dismissWithClickedButtonIndex:1 animated:YES];
}
-(void)Cancel_picker:(id)sender{
[pickerViewPopup dismissWithClickedButtonIndex:1 animated:YES];
}