Skip to content

A simple replacement for the UITableView section index bar

License

Notifications You must be signed in to change notification settings

alexanderpepper/CMIndexbar.swift

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

CMIndexBar.swift

CMIndexBar allows you to modify the colors, font, and size of UITableView's index bar.

This is a Swift port of the original CMIndexBar library

Usage

Initialization

let rect = CGRect(x: view.frame.size.width - 35,
                  y: 10.0,
                  width: 28.0,
                  height: view.frame.size.height - 20)
indexBar = CMIndexBar(frame: rect)
indexBar.textColor = UIColor.darkGray
indexBar.highlightedBackgroundColor = UIColor.lightGray
indexBar.font = UIFont(name: "TimesNewRomanPS-BoldMT", size: 12.0)        
indexBar.delegate = self
indexBar.setIndexes(["A", "B", "C", ...])
view.addSubview(indexBar)

Delegate

func indexSelectionDidChange(_ indexBar: CMIndexBar, index: Int, title: String) {
  let indexPath = IndexPath(row: 0, section: index)
  table.scrollToRow(at: indexPath, at: .top, animated: false)
}

License

MIT © 2018 Alex Pepper

About

A simple replacement for the UITableView section index bar

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages