项目介绍:
自己封装了一个简单的下拉列表控件
使用方法:
- – (void)viewDidLoad {
- [super viewDidLoad];
- JJOptionView *view = [[JJOptionView alloc] initWithFrame:CGRectMake(100, 700, 200, 40)];
- view.dataSource = @[@"111",@"222",@"333",@"444",@"555"];
- view.selectedBlock = ^(JJOptionView * _Nonnull optionView, NSInteger selectedIndex) {
- NSLog(@"%@",optionView);
- NSLog(@"%ld",selectedIndex);
- };
- [self.view addSubview:view];
- JJOptionView *view1 = [[JJOptionView alloc] initWithFrame:CGRectMake(100, 300, 200, 40)];
- view1.dataSource = @[@"1",@"2",@"3",@"4",@"5"];
- view1.delegate = self;
- [self.view addSubview:view1];
- // Do any additional setup after loading the view, typically from a nib.
- }
- – (void)optionView:(JJOptionView *)optionView selectedIndex:(NSInteger)selectedIndex {
- NSLog(@"%@",optionView);
- NSLog(@"%ld",selectedIndex);
- }
复制代码
demo地址:https://github.com/SoulmateL/JJOptionView