Dropdown

final class Dropdown : UIView
extension Dropdown: UITableViewDataSource, UITableViewDelegate

A Material Design dropdown in replacement for UIPickerView.

Properties

  • The current visible dropdown. There can be only one visible dropdown at a time.

    Declaration

    Swift

    weak static var VisibleDropdown: Dropdown?

UI

  • The view to which the dropdown will displayed onto.

    Declaration

    Swift

    weak var anchorView: AnchorView? { get set }
  • The possible directions where the dropdown will be showed.

    See Direction enum for more info.

    Declaration

    Swift

    var direction: Dropdown.Direction
  • The offset point relative to anchorView when the dropdown is shown above the anchor view.

    By default, the dropdown is showed onto the anchorView with the top left corner for its origin, so an offset equal to (0, 0). You can change here the default dropdown origin.

    Declaration

    Swift

    var topOffset: CGPoint { get set }
  • The offset point relative to anchorView when the dropdown is shown below the anchor view.

    By default, the dropdown is showed onto the anchorView with the top left corner for its origin, so an offset equal to (0, 0). You can change here the default dropdown origin.

    Declaration

    Swift

    var bottomOffset: CGPoint { get set }
  • The offset from the bottom of the window when the dropdown is shown below the anchor view. Dropdown applies this offset only if keyboard is hidden.

    Declaration

    Swift

    var offsetFromWindowBottom: CGFloat { get set }
  • The width of the dropdown.

    Defaults to anchorView.bounds.width - offset.x.

    Declaration

    Swift

    var width: CGFloat? { get set }
  • arrowIndication.x

    arrowIndication will be add to tableViewContainer when configured

    Declaration

    Swift

    var arrowIndicationX: CGFloat? { get set }

Appearance

  • Cell height

    Declaration

    Swift

    @objc
    dynamic var cellHeight: CGFloat { get set }
  • Background color

    Declaration

    Swift

    override var backgroundColor: UIColor? { get set }
  • The color of the dimmed background (behind the dropdown, covering the entire screen).

    Declaration

    Swift

    var dimmedBackgroundColor: UIColor { get set }
  • The background color of the selected cell in the dropdown.

    Changing the background color automatically reloads the dropdown.

    Declaration

    Swift

    @objc
    dynamic var selectionBackgroundColor: UIColor
  • The separator color between cells.

    Changing the separator color automatically reloads the dropdown.

    Declaration

    Swift

    @objc
    dynamic var separatorColor: UIColor { get set }
  • The corner radius of Dropdown.

    Changing the corner radius automatically reloads the dropdown.

    Declaration

    Swift

    @objc
    dynamic var ddCornerRadius: CGFloat { get set }
  • Alias method for ddCornerRadius variable to avoid ambiguity.

    Declaration

    Swift

    @objc
    dynamic func setupCornerRadius(_ radius: CGFloat)
  • The masked corners of Dropdown.

    Changing the masked corners automatically reloads the dropdown.

    Declaration

    Swift

    @objc
    dynamic func setupMaskedCorners(_ cornerMask: CACornerMask)
  • The color of the shadow.

    Changing the shadow color automatically reloads the dropdown.

    Declaration

    Swift

    @objc
    dynamic var shadowColor: UIColor { get set }
  • The offset of the shadow.

    Changing the shadow color automatically reloads the dropdown.

    Declaration

    Swift

    @objc
    dynamic var shadowOffset: CGSize { get set }
  • The opacity of the shadow.

    Changing the shadow opacity automatically reloads the dropdown.

    Declaration

    Swift

    @objc
    dynamic var shadowOpacity: Float { get set }
  • The radius of the shadow.

    Changing the shadow radius automatically reloads the dropdown.

    Declaration

    Swift

    @objc
    dynamic var shadowRadius: CGFloat { get set }
  • The duration of the show/hide animation.

    Declaration

    Swift

    @objc
    dynamic var animationduration: Double
  • The option of the show animation. Global change.

    Declaration

    Swift

    static var animationEntranceOptions: UIView.AnimationOptions
  • The option of the hide animation. Global change.

    Declaration

    Swift

    static var animationExitOptions: UIView.AnimationOptions
  • The option of the show animation. Only change the caller. To change all dropdown’s use the static var.

    Declaration

    Swift

    var animationEntranceOptions: UIView.AnimationOptions
  • The option of the hide animation. Only change the caller. To change all dropdown’s use the static var.

    Declaration

    Swift

    var animationExitOptions: UIView.AnimationOptions
  • The downScale transformation of the tableview when the Dropdown is appearing

    Declaration

    Swift

    var downScaleTransform: CGAffineTransform { get set }
  • The color of the text for each cells of the dropdown.

    Changing the text color automatically reloads the dropdown.

    Declaration

    Swift

    @objc
    dynamic var textColor: UIColor { get set }
  • The color of the text for selected cells of the dropdown.

    Changing the text color automatically reloads the dropdown.

    Declaration

    Swift

    @objc
    dynamic var selectedTextColor: UIColor { get set }
  • The font of the text for each cells of the dropdown.

    Changing the text font automatically reloads the dropdown.

    Declaration

    Swift

    @objc
    dynamic var textFont: UIFont { get set }
  • The NIB to use for DropdownCells

    Changing the cell nib automatically reloads the dropdown.

    Declaration

    Swift

    var cellNib: UINib { get set }

Content

Initialization

Actions

  • An Objective-C alias for the show() method which converts the returned tuple into an NSDictionary.

    Declaration

    Swift

    @objc(show)
    func objc_show() -> NSDictionary

    Return Value

    NSDictionary with “canBeDisplayed” Bool, and possibly for the “offScreenHeight” Optional(CGFloat).

  • Shows the dropdown if enough height.

    Declaration

    Swift

    @discardableResult
    func show(onTopOf window: UIWindow? = nil,
              beforeTransform transform: CGAffineTransform? = nil,
              anchorPoint: CGPoint? = nil) -> (canBeDisplayed: Bool, offscreenHeight: CGFloat?)

    Return Value

    Wether it succeed and how much height is needed to display all cells at once.

  • Hides the dropdown.

    Declaration

    Swift

    func hide()

UITableView

Objective-C methods for converting the Swift type Index

Keyboard events

  • Starts listening to keyboard events. Allows the dropdown to display correctly when keyboard is showed.

    Declaration

    Swift

    @objc
    static func startListeningToKeyboard()