FUISliderCollectionViewCell
@MainActor
open class FUISliderCollectionViewCell : FUIInlineValidationDrawingCollectionViewCell<FUISliderFormView>, FUIFormCell
A customized UICollectionViewCell
containing an FUISliderFormView
. It allows users to select a single value from a continuous range of values.
The developer should set the following properties on the cell, in their implementation of UICollectionViewDataSource
cellForItem(at:)
function:
title
: The key name of the propertyvalue
: The value of the property, asFloat
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 isnil
.formatter
: The formatter to format the presentation of unit.isEditable
: Indicates if the cell’s value may be modified. Defaults totrue
.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
@MainActor open var title: String? { get set }
-
Undocumented
Declaration
Swift
@MainActor open var isEnabled: Bool { get set }
-
Declaration
Swift
@MainActor open var value: Float { get set }
-
Declaration
Swift
@MainActor open var isEditable: Bool { get set }
-
Declaration
Swift
@MainActor open var onChangeHandler: ((Float) -> Void)? { get set }
-
The maximum value of the slider.
Declaration
Swift
@MainActor open var maximumValue: Float { get set }
-
The minimum value of the slider.
Declaration
Swift
@MainActor open var minimumValue: Float { get set }
-
A Boolean value indicating whether changes in the slider’s value generate continuous update events.
Declaration
Swift
@MainActor open var isContinuous: Bool { get set }
-
The unit of measure for value.
Declaration
Swift
@MainActor open var unit: Unit? { get set }
-
The formatter to format the presentation of unit.
Declaration
Swift
@MainActor open var formatter: MeasurementFormatter { get set }
-
Declaration
Swift
@MainActor open override func prepareForReuse()