Author | 小小聪明屋 |
---|---|
[email protected] | |
GitHub | https://github.com/fanxiaocong |
Blog | http://www.cnblogs.com/fanxiaocong |
简单封装的下拉列表,支持多段显示
XCDropdownSegment *segment = [[XCDropdownSegment alloc] initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, SCREEN_HEIGHT-64)];
segment.dataSource = self;
segment.delegate = self;
[self.view addSubview:segment];
if (1 == self.sectionCount)
{
[segment updateConfigure:^(XCDropdownSegmentConfigure *confi) {
confi.headerSelectedTitleColor = [UIColor redColor];
confi.rowHeight = 40;
}];
}
- (NSArray<NSString *> *)titlesOfHeaderInDropdownSegment:(XCDropdownSegment *)dropdownSegment
段头标题显示的文字,可以是多段,需要一个数组返回
- (NSArray<NSString *> *)titlesOfHeaderInDropdownSegment:(XCDropdownSegment *)dropdownSegment
{
return @[@"第一段", @"第二段", @"第三段"];
}
- (NSArray<NSString *> *)dropdownSegment:(XCDropdownSegment *)dropdownSegment titlesInSection:(NSInteger)section
每段显示的文字数组,可以根据不同的 section
来返回不同的内容
- (NSArray<NSString *> *)dropdownSegment:(XCDropdownSegment *)dropdownSegment titlesInSection:(NSInteger)section
{
return @[
@"三:001",
@"三:002",
@"三:003",
@"三:004",
@"三:005"
];
}
- (void)dropdownSegment:(XCDropdownSegment *)dropdownSegment didSelectHeaderInSection:(NSInteger)section
点击第 section 段的头部的回调
- (void)dropdownSegment:(XCDropdownSegment *)dropdownSegment didSelectRow:(NSInteger)row inSection:(NSInteger)section
点击第 section 段的第 row 行的回调
pod 'XCDropdownSegment'