PickerView
public struct PickerView<T> : View
Wrapper of UIPickerView.
A view that uses a spinning-wheel or slot-machine metaphor to show one or more sets of values.
PickerView($pickerData) { item in
Text(item).grow(1).textAlign(.center)
}
.width(100%)
.height(50)
.widthForComponent({ (component) -> Float in
return 50
})
.rowHeightForComponent({ (component) -> Float in
return 44
})
.didSelectRow({ (text, row, component) in
// Did select action
})
-
Declaration
Swift
public var body: View { get }
-
Declaration
Swift
public var type: ArgoKitNodeType { get }
-
Declaration
Swift
public var node: ArgoKitNode? { get }
-
init the PickerView
Declaration
Swift
public init(_ data: DataSource<DataList<T>>, @ArgoKitViewBuilder rowContent: @escaping (T) -> View)
Parameters
data
data source of the picker view
rowContent
View Builder for the picker view
-
init the PickerView
Declaration
Swift
public init(_ data: DataSource<SectionDataList<T>>, @ArgoKitViewBuilder rowContent: @escaping (T) -> View)
Parameters
data
data source of the picker view
rowContent
View Builder for the picker view
-
reload all components of the picker view
Calling this method causes the picker view to query the delegate for new data for all components.
Declaration
Swift
@discardableResult public func reloadAllComponents() -> PickerView<T>
Parameters
data
the new data source
Return Value
self
-
Reloads a particular component of the picker view.
Calling this method causes the picker view to query the delegate for new data for the given component.
Declaration
Swift
@discardableResult public func reloadComponent(_ component: Int) -> PickerView<T>
Parameters
data
the new data source
component
A zero-indexed number identifying a component of the picker view.
Return Value
self
-
A zero-indexed number identifying a component of the picker view.
Declaration
Swift
@discardableResult public func selectRow(_ row: Int, inComponent component: Int, animated: Bool) -> PickerView<T>
Parameters
row
A zero-indexed number identifying a row of component.
component
A zero-indexed number identifying a component of the picker view.
animated
true to animate the selection by spinning the wheel (component) to the new value; if you specify false, the new selection is shown immediately.
Return Value
self
-
set the callback called when it needs the row width to use for drawing row content.
Declaration
Swift
@discardableResult public func widthForComponent(_ action: @escaping (_ component: Int) -> Float) -> PickerView<T>
Parameters
action
the callback
Return Value
Self
-
set the callback called when it needs the row height to use for drawing row content.
Declaration
Swift
@discardableResult public func rowHeightForComponent(_ action: @escaping (_ component: Int) -> Float) -> PickerView<T>
Parameters
action
the callback
Return Value
Self
-
set the callback called when the row is selected
Declaration
Swift
@discardableResult public func didSelectRow(_ action: @escaping (_ data: T, _ row: Int, _ component: Int) -> Void) -> PickerView<T>
Parameters
action
the callback
Return Value
self