#import "ViewController.h" @interface ViewController ()<UIPickerViewDataSource,UIPickerViewDelegate> @property (nonatomic,strong) UIPickerView *pickerView; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; [self.view addSubview:self.pickerView]; Self. PickerView. BackgroundColor = [[UIColor orangeColor] colorWithAlphaComponent: 0.1]; self.navigationController.navigationBarHidden = YES; } / / how many columns - (NSInteger) numberOfComponentsInPickerView: (UIPickerView *) pickerView {return 2; } // how many rows in a row - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {return 10; } // what title is displayed for each row of each column - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { return @"silence"; } // return the width of the first column - (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component {return 150; } // returns the height of the first row of each column - (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component {return 150; } // Call - (void)pickerView (UIPickerView *)pickerView didSelectRow (NSInteger)row inComponent:(NSInteger)component { NSLog(@"component = %ld-----row = %ld",component,row); } - (UIPickerView *)pickerView { if (! _pickerView) { _pickerView = [[UIPickerView alloc] init]; _pickerView.frame = self.view.bounds; _pickerView.delegate = self; _pickerView.dataSource = self; } return _pickerView; } @endCopy the code