IconSelector
@available(iOSApplicationExtension, unavailable)
public class IconSelector : UIControl, UIGestureRecognizerDelegate
A control that presents available icons and allows selection.
This control will not actually perform any updates based on the user’s selection. It is the responsibility of
the parent UIViewController to perform the update. There are two methods to perform the actual updates.
- Read the
selectedIconupon the user indicating they’re done. - Use
addTarget(_:action:for:)to enroll in updates for the.valueChangedevent.
-
Undocumented
Declaration
Swift
public let icons: [Icon] -
Creates an
IconSelectorin the given frame, with the given icons.Declaration
Swift
public init(frame: CGRect, icons: [Icon])Parameters
frameFrame to put this control within
iconsIcons to display
-
Creates an
IconSelectorin the given frame, with the givenBundle.Declaration
Swift
public convenience init(frame: CGRect, bundle: Bundle = .main)Parameters
frameFrame to put this control within
bundleBundleto pull icons from; defaults to themainbundle. -
Creates an
IconSelectorwith the given iconsDeclaration
Swift
public convenience init(icons: [Icon])Parameters
iconsIcons to display
-
Creates an
IconSelectorfor the givenBundleDeclaration
Swift
public convenience init(bundle: Bundle = .main)Parameters
bundleBundleto load the icons from; defaults to themainbundle. -
Undocumented
Declaration
Swift
public override func didMoveToSuperview() -
Gets the currently selected icon.
Declaration
Swift
public var selectedIcon: Icon? { get set } -
Undocumented
Declaration
Swift
override public var isEnabled: Bool { get set } -
Undocumented
Declaration
Swift
override public var layoutMargins: UIEdgeInsets { get set }
-
Undocumented
Declaration
Swift
public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool
-
Gets or sets the size of the icons to display
Declaration
Swift
public var iconSize: CGFloat { get set } -
Gets or sets the width of the selection stroke
Declaration
Swift
public var selectionStrokeWidth: CGFloat { get set } -
Gets or sets the stroke color for unselected icons
Declaration
Swift
public var unselectedStrokeColor: UIColor? { get set } -
Flag to indicate if icon labels should be displayed. Defaults to
false.Declaration
Swift
public var shouldDisplayLabels: Bool { get set } -
Flag to indicate if the icons are lined up with the leading and trailing edges of the
IconSelectorview.When
true, the spacing between the horizontal edges of the parent view is fixed, pinning the respective edges of the icons within the first and last columns to theIconSelectorview. This is useful when lining the horizontal edges of theIconSelectorup with other edges, such as displaying within a table view, as the visual edges are fixed.When
falsethe spacing between the horizontal edges of the parent view is flexible, and sized to match the space between the icons themselves. This is useful when pinning theIconSelectoritself to the edges of the device’s screen, as it ensures even spacing for the icons, replicating the look of the iOS springboard layout.Note
The width of icon labels (if enabled) cannot exceed the width of the icons themselves if this setting is enabled, and will be truncated as required. If edges are not anchored, icon labels can fill the available space as needed, similar to how they would be displayed on the iOS springboard.Declaration
Swift
public var anchorHorizontalEdges: Bool { get set } -
Gets or sets a flag to have this control adjust its height to fit the content it is displaying.
Declaration
Swift
public var adjustHeightToFitContent: Bool { get set } -
Undocumented
Declaration
Swift
override public func layoutSubviews() -
Undocumented
Declaration
Swift
override public func updateConstraints()
View on GitHub
IconSelector Class Reference