FUISliderCollectionViewCell

A customized UICollectionViewCell containing an FUISliderFormView. It allows users to select a single value from a continuous range of values.

FUISliderFormCell

The developer should set the following properties on the cell, in their implementation of UICollectionViewDataSource cellForItem(at:) function:

  • title: The key name of the property
  • value: The value of the property, as Float
  • minimumValue: The minimum value of the selection range.
  • maximumValue: The maximum value of the selection range.

And an onChangeHandler:

  • onChangeHandler: a handler closure, which is invoked on changes to the value.

Optionally, the developer may set:

  • unit: The unit of value. Default is nil.
  • formatter: The formatter to format the presentation of unit.
  • isEditable: Indicates if the cell’s value may be modified. Defaults to true.
  • isContinuous: A Boolean value indicating whether changes in the slider’s value generate continuous update events.

The following is an example of usage in an application UICollectionViewController:

override func viewDidLoad() {
    super.viewDidLoad()
    self.collectionView.register(FUISliderCollectionViewCell, forCellReuseIdentifier: FUISliderCollectionViewCell.reuseIdentifier)
    // ...
}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {

    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: FUISliderCollectionViewCell.reuseIdentifier, for: indexPath) as! FUISliderCollectionViewCell
    cell.title = "Distance"
    cell.minimumValue = 0
    cell.maximumValue = 30
    cell.value = 10

    // MARK:  implement an onChangeHandler
    cell.onChangeHandler = { [weak self] newValue in
        self.myObject.distance = newValue
    }

    return cell
}

Theming

Supported style classes

FUISliderCollectionViewCell
FUISliderCollectionViewCell_title
FUISliderCollectionViewCell_subtitle
FUISliderCollectionViewCell_footnote
FUISliderCollectionViewCell_slider
  • Undocumented

    Declaration

    Swift

    open var title: String? { get set }
  • Undocumented

    Declaration

    Swift

    open var isEnabled: Bool { get set }
  • Declaration

    Swift

    open var value: Float { get set }
  • Declaration

    Swift

    open var isEditable: Bool { get set }
  • Declaration

    Swift

    open var onChangeHandler: ((Float) -> Void)? { get set }
  • The maximum value of the slider.

    Declaration

    Swift

    open var maximumValue: Float { get set }
  • The minimum value of the slider.

    Declaration

    Swift

    open var minimumValue: Float { get set }
  • A Boolean value indicating whether changes in the slider’s value generate continuous update events.

    Declaration

    Swift

    open var isContinuous: Bool { get set }
  • The unit of measure for value.

    Declaration

    Swift

    open var unit: Unit? { get set }
  • The formatter to format the presentation of unit.

    Declaration

    Swift

    open var formatter: MeasurementFormatter { get set }