https://github.com/davecom/dkdropmenu
A simple iOS drop down list written in Swift.
https://github.com/davecom/dkdropmenu
Last synced: 11 months ago
JSON representation
A simple iOS drop down list written in Swift.
- Host: GitHub
- URL: https://github.com/davecom/dkdropmenu
- Owner: davecom
- License: other
- Created: 2015-06-06T03:26:48.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2017-09-18T04:05:05.000Z (over 8 years ago)
- Last Synced: 2025-06-05T04:22:57.942Z (about 1 year ago)
- Language: Swift
- Size: 127 KB
- Stars: 25
- Watchers: 4
- Forks: 10
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# DKDropMenu
DKDropMenu is a simple iOS drop down list written in Swift. It expands and collapses. It allows the user to select only one item at a time. Items are just Strings. A delegate is notified when selection occurs. DKDropMenu is IBDesignable and IBInspectable with customizable colors, font, and row heights.


## Installation
Use the cocoapod `DKDropMenu` or simply include `DKDropMenu.swift` in your project. DKDropMenu 0.3.0 and above requires Swift 4. Use version 0.2.0 for Swift 3 Support. Use version 0.1.6 for Swift 2 support.
## Usage
Create a DKDropMenu in IB or in code (using UIView's init methods). Then add items and set a delegate:
```
dropMenu.add(names: ["hello", "goodbye", "why?"])
dropMenu.delegate = self
```
Make sure to implement the single method the delegate (DKDropMenuDelegate) must implement:
```
func itemSelected(withIndex: Int, name: String) {
println("\(name) selected");
}
```
The delegate can also optionally implement the method
```
func collapsedChanged()
```
to be notified when the collapse status of the menu changes.
Items can be added or removed
```
func add(names: [String])
func add(name: String)
func remove(atIndex: Int)
func remove(name: String)
func removeAll()
```
The properties `collapsed` (Bool) and `selectedItem` (String) can be manually modified.
## License and Authorship
Released under the MIT License. Copyright 2015-2016 David Kopec. Please open issues on GitHub.