Skip to content

Customizing the UITableView's section index written in Swift

License

Notifications You must be signed in to change notification settings

mohsinalimat/SectionIndexView

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

中文介绍

SectionIndexView

SectionIndexView which could be highly customized, can easily be used to customize the UITableView's section index .

Overview

Demo Overview Demo Overview Demo Overview Demo Overview Demo Overview

Installation

pod 'SectionIndexView'

Usage

SectionIndexView is easy to use, API are like UITableView.

Init SectionIndexView .

override func viewDidLoad() {
    ......
    indexView = SectionIndexView.init(frame:frame)
    indexView.dataSource = self
    indexView.delegate = self
    view.addSubview(indexView)
    indexView.loadData()     // important
}

Conforming to protocol SectionIndexViewDataSource.

func numberOfItemViews(in sectionIndexView: SectionIndexView) -> Int {
    return indexData.count
}

func sectionIndexView(_ sectionIndexView: SectionIndexView, itemViewAt section: Int) -> SectionIndexViewItem {
    let itemView = SectionIndexViewItem.init()
    itemView.title = indexData[section]
    return itemView
}
// when you need SectionIndexViewItemPreview
func sectionIndexView(_ sectionIndexView: SectionIndexView, itemPreviewFor section: Int) -> SectionIndexViewItemPreview {
    let preview = SectionIndexViewItemPreview.init(title: indexData[section], type: .default)
    return preview
}

Conforming to protocol SectionIndexViewDelegate. All of them are optional.

//didSelect
func sectionIndexView(_ sectionIndexView: SectionIndexView, didSelect section: Int)

//toucheMoved
func sectionIndexView(_ sectionIndexView: SectionIndexView, toucheMoved section: Int)

//toucheCancelled
func sectionIndexView(_ sectionIndexView: SectionIndexView, toucheCancelled section: Int)

Please see the demo for more details.

License

SectionIndexView is released under an MIT license.

About

Customizing the UITableView's section index written in Swift

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages

  • Swift 96.4%
  • Ruby 3.6%