Latest 0.1.0
Homepage https://github.com/alexanderkorus/DropdownButton
License MIT
Platforms ios 11.0
Dependencies SnapKit
Authors

CI Status
Version
License
Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Preview

Requirements

Installation

DropdownButton is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'DropdownButton'

Basic usage

// Defining dropdown button like a UIbutton and configure it
let dropDownButton: DropdownButton = {
    let button: DropdownButton = DropdownButton()
    button.layer.cornerRadius = 10
    button.backgroundColor = .green
    button.setTitleColor(.white, for: .normal)
    button.selectedRowColor = .lightGray
    button.selectedRowTextColor = .white
    button.rowHeight = 40
    return button
}()

// The the Closure returns Selected Index and String 
dropDownButton.didSelect { (selectedText , index ,id) in
        self.valueLabel.text = "Selected String: (selectedText) n index: (index)"
}

// seting options 
let options = ["Option 1", "Option 2", "Option 3"]
let ids = [0, 1, 2]

dropDownButton.setOptions(options: options, optionIds: ids, selectedIndex: 0)

Other Options

Actions

dropDownButton.expandList()  // To show the Drop Down Menu
dropDownButton.collapseList() // To hide the Drop Down Menu

Closures

listWillAppear() {
//You can Do anything when Dropdown menu willAppear 
}

listDidAppear() {
//You can Do anything when Dropdown menu listDidAppear
}

listWillDisappear() {
//You can Do anything when Dropdown menu listWillDisappear 
}

listDidDisappear() {
//You can Do anything when Dropdown menu listDidDisappear
}

Customize DropdownButton

You can customize these properties of the drop down:

  • hideOptionsWhenSelect : This option to hide the list when click option one item. Default value is true
  • selectedRowColor : Color of selected Row item in DropDown Default value is .cyan
  • rowBackgroundColor : Color of DropDown Default value is .white
  • listHeight: The maximum Height of of List. Default value is 150
  • rowHeight: The Height of of List in the List. Default value is 30
  • selectedIndex: For preSelection of any of item in list

Note :

1.If you are using Multiple Drop Downs in a Single ViewController, Must Kept reverse order on StoryBoard or addSubview() to avoid Overlaying

Author

Alexander Korus, [email protected], based on iOSDropDown Library by jriosdev.

License

DropdownButton is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "DropdownButton",
    "version": "0.1.0",
    "summary": "A button which open a dropwdown with selectable elements.",
    "description": "A customizable button which open a dropwdown with selectable elements. Based on iOSDropDown Library by jriosdev.",
    "homepage": "https://github.com/alexanderkorus/DropdownButton",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "alexanderkorus": "[email protected]"
    },
    "source": {
        "git": "https://github.com/alexanderkorus/DropdownButton.git",
        "tag": "0.1.0"
    },
    "platforms": {
        "ios": "11.0"
    },
    "source_files": "DropdownButton/Classes/**/*",
    "dependencies": {
        "SnapKit": [
            "~> 4.2.0"
        ]
    },
    "swift_version": "4.2"
}

Pin It on Pinterest

Share This