Skip to content

About

LabelPicker is available to add labels for components to UIPickerView.

Topics

Resources

Stars

13 stars

Watchers

0 watching

Forks

Latest commit

 

History

73 Commits

Folders and files

Repository files navigation

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

let hours = (0...23).map { "\($0)" }
let min = (0...59).map { "\($0)" }
let sec = (0...59).map { "\($0)" }
let attributes: [NSAttributedString.Key: Any] = [.font: UIFont.systemFont(ofSize: 16.0)]

let itemsComponents = [hours, min, sec]
    .map { ItemsComponent(items: $0, attributes: attributes, maxWidth: 20.0) }
let labelComponents = [("hours", 50.0), ("min", 30.0), ("sec", 30.0)]
    .map { LabelComponent(name: $0, attributes: attributes, width: $1) }
let components = zip(itemsComponents, labelComponents).map(LabelPickerComponent.init)

let pickerView = LabelPickerView()
pickerView.rowHeight = 30.0
pickerView.components = components

view.addSubview(pickerView)

See Demo for more info.

Requirements

  • iOS 10.0
  • Xcode 9.0
  • Swift 4.0

Installation

Specify LabelPicker as a dependency of your Package.swift.

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

Add this to your Cartfile:

github "komaji/LabelPicker"

Then, run the following command:

$ carthage update

Lisence

MIT

About

LabelPicker is available to add labels for components to UIPickerView.

Topics

Resources

Stars

13 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages