Awesome Open Source
Awesome Open Source


default custom image
default custom image



pod 'SectionIndexView'

Swift Package Manager

  • File > Swift Packages > Add Package Dependency
  • Select "Up to Next Major" with "2.0.1"


Drop the swift files inside of SectionIndexViewDemo/SectionIndexView into your project.



override func viewDidLoad() {
    let titles = ["A","B","C","D","E","F","G"]
    let items = titles.compactMap { (title) -> SectionIndexViewItem? in
            let item = SectionIndexViewItemView.init()
            item.title = title
            item.indicator = SectionIndexViewItemIndicator.init(title: title)
            return item
    self.tableView.sectionIndexView(items: items)


- (void)viewDidLoad {
    [super viewDidLoad];
    NSMutableArray<UIView<SectionIndexViewItem>*> *items = [[NSMutableArray alloc]init];
    NSArray *titles = @[@"A",@"B",@"C",@"D",@"E",@"F",@"G"];
    for (NSString *title in titles) {
        SectionIndexViewItemView *item = [[SectionIndexViewItemView alloc] init];
        item.title = title
        item.indicator = [[SectionIndexViewItemIndicator alloc]initWithTitle:title];
        [items addObject:item];
    [self.tableView sectionIndexViewWithItems:[NSArray arrayWithArray:items]];


In order to assure SectionIndexView has correct scrolling when your navigationBar not hidden and UITableView use contentInsetAdjustmentBehavior or automaticallyAdjustsScrollViewInsets to adjust content. Set adjustedContentInset value equal to UITableViews adjustment content inset

override func viewDidLoad() {
    let navigationBarHeight = self.navigationController.navigationBar.frame.height
    let statusBarHeight = UIApplication.shared.statusBarFrame.size.height
    let frame = CGRect.init(x: 0, y: 0, width: width, height: height)
    let tableView = UITableView.init(frame: frame, style: .plain)
    let configuration = SectionIndexViewConfiguration.init()
    configuration.adjustedContentInset = statusBarHeight + navigationBarHeight
    tableView.sectionIndexView(items: items, configuration: configuration)

If you want to control the UITableView and SectionIndexView manuallyyou can use it like this. There is an example.

override func viewDidLoad() {
    let indexView = SectionIndexView.init(frame: frame)
    indexView.delegate = self
    indexView.dataSource = self

Please see the demo for more details.


All source code is licensed under the License

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Index (407
Uitableview (339
Related Projects