项目作者: lalkrishna

项目描述 :
Customizable Ruler-Picker backed by UICollectionView
高级语言: Swift
项目地址: git://github.com/lalkrishna/LKRulerPicker.git
创建时间: 2020-10-18T15:01:42Z
项目社区:https://github.com/lalkrishna/LKRulerPicker

开源协议:

下载


LKRulerPicker

Customizable Ruler picker

Installation

Swift Package Manager

File / Swift Packages / Add Package Dependency… and enter package repository URL: https://github.com/lalkrishna/LKRulerPicker and follow the instructions.

Manually

Clone the repo and Drag and drop to your project (it will be added as a package)
OR
You can just copy the file: Sources/LKRulerPicker/LKRulerPicker.swift

Usage

Via Storyboard

Create UIView
Assign class and Module as: LKRulerPicker

Programatically

  1. import LKRulerPicker
  2. private lazy var heightPicker: LKRulerPicker = {
  3. $0.dataSource = self
  4. $0.delegate = self
  5. $0.tintColor = UIColor.black.withAlphaComponent(0.5)
  6. $0.highlightLineColor = .black
  7. $0.highlightTextColor = .black
  8. return $0
  9. }(LKRulerPicker())
  10. view.addSubview(heightPicker)

Configuration

  1. let heightMetrics = LKRulerPickerConfiguration.Metrics(
  2. minimumValue: 50,
  3. defaultValue: 150,
  4. maximumValue: 300,
  5. divisions: 5,
  6. fullLineSize: 38,
  7. midLineSize: 28,
  8. smallLineSize: 28)
  9. heightPicker.configuration = LKRulerPickerConfiguration(
  10. scrollDirection: .vertical,
  11. alignment: .start,
  12. metrics: heightMetrics,
  13. isHapticsEnabled: false)

Delegation/Datasource

  1. public protocol LKRulerPickerDataSource: class {
  2. func rulerPicker(_ picker: LKRulerPicker, titleForIndex index: Int) -> String?
  3. func rulerPicker(_ picker: LKRulerPicker, highlightTitleForIndex index: Int) -> String?
  4. }
  5. public protocol LKRulerPickerDelegate: class {
  6. func rulerPicker(_ picker: LKRulerPicker, didSelectItemAtIndex index: Int)
  7. }