项目作者: komaji

项目描述 :
LabelPicker is available to add labels for components to UIPickerView.
高级语言: Swift
项目地址: git://github.com/komaji/LabelPicker.git
创建时间: 2017-03-30T14:41:21Z
项目社区:https://github.com/komaji/LabelPicker

开源协议:MIT License

下载


LabelPicker

Build Status
Language
Platform
Carthage compatible
Swift Package Manager
License

LabelPicker is available to add labels for components to UIPickerView.
Frame of components and labels is calicurated automaticaly from your specified values of items and labels width.

https://gyazo.com/41ae851edca077bd87f2cea8422781ba

Usage

  1. let hours = (0...23).map { "\($0)" }
  2. let min = (0...59).map { "\($0)" }
  3. let sec = (0...59).map { "\($0)" }
  4. let attributes: [NSAttributedString.Key: Any] = [.font: UIFont.systemFont(ofSize: 16.0)]
  5. let itemsComponents = [hours, min, sec]
  6. .map { ItemsComponent(items: $0, attributes: attributes, maxWidth: 20.0) }
  7. let labelComponents = [("hours", 50.0), ("min", 30.0), ("sec", 30.0)]
  8. .map { LabelComponent(name: $0, attributes: attributes, width: $1) }
  9. let components = zip(itemsComponents, labelComponents).map(LabelPickerComponent.init)
  10. let pickerView = LabelPickerView()
  11. pickerView.rowHeight = 30.0
  12. pickerView.components = components
  13. view.addSubview(pickerView)

See Demo for more info.

Requirements

  • iOS 10.0
  • Xcode 9.0
  • Swift 4.0

Installation

Swift Package Manager

Specify LabelPicker as a dependency of your Package.swift.

  1. dependencies: [
  2. .package(url: "https://github.com/komaji/LabelPicker.git", .upToNextMajor(from: "VERSION_NUMBER")),
  3. ],

Carthage

Add this to your Cartfile:

  1. github "komaji/LabelPicker"

Then, run the following command:

  1. $ carthage update

Lisence

MIT