self.pickerContainerView = [[UIView alloc] initWithFrame:CGRectMake(0, 194, 320, 224)]; self.pickerContainerView.backgroundColor = [UIColor clearColor]; [self.view addSubview:self.pickerContainerView]; UIToolbar *pickerToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)]; pickerToolbar.barStyle = UIBarStyleBlackTranslucent; [pickerToolbar sizeToFit]; self.lblPickerViewTitle = [[UILabel alloc] initWithFrame:CGRectMake(15, 7, 230, 30)]; self.lblPickerViewTitle.backgroundColor = [UIColor clearColor]; [self.lblPickerViewTitle setFont: [UIFont fontWithName:@"Arial-BoldMT" size:17]]; self.lblPickerViewTitle.textAlignment = UITextAlignmentLeft; self.lblPickerViewTitle.textColor =[UIColor whiteColor]; [pickerToolbar addSubview:self.lblPickerViewTitle]; NSMutableArray *barItems = [[NSMutableArray alloc] init]; UIBarButtonItem *flexSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil]; [barItems addObject:flexSpace]; [flexSpace release]; UIBarButtonItem *btnCancel = [[UIBarButtonItem alloc] initWithTitle:@"Cancel" style:UIBarButtonItemStyleBordered target:self action:@selector(closePickerView:)]; [barItems addObject:btnCancel]; [btnCancel release]; UIBarButtonItem *btnDone = [[UIBarButtonItem alloc] initWithTitle:@"ShowPicker" style:UIBarButtonItemStyleBordered target:self action:@selector(donePickerView:)]; [barItems addObject:btnDone]; [btnDone release]; [pickerToolbar setItems:barItems animated:YES]; [barItems release]; [self.pickerContainerView addSubview:pickerToolbar];
And in ShowPicker , write code to display UIPicker
user2289379
source share