update readme
A simple fully customizable dropdown.
The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.
swift
Once you have your Swift package set up, add SwiftDropdown to the dependencies value of your Package.swift.
dependencies
Package.swift
dependencies: [ .package(url: "https://github.com/giuseppebruno/SwiftDropdown.git", .upToNextMajor(from: "1.0.0")) ]
Add a UIView from the Storyboard and subclass as SwiftDropdown or create a SwiftDropdown view from code.
UIView
SwiftDropdown
import SwiftDropdown ... let dropdown = SwiftDropdown() dropdown.placeholderText = "Select..." dropdown.options = ["Option 1", "Option 2", "Option 3"]
You can customize the Dropdown as follow:
boxBackgroundColor
placeholderFont
placeholderColor
arrowImage
arrowPosition
cornerRadius
borderWidth
borderColor
disableArrowAnimation
dropdownHeight
itemsRowHeight
itemsFont
itemsTextColor
disableTapToDismiss
dropdownExtraSpace
itemsBackgroundColor
showSelectedItemCheckmark
checkmarkColor
highlightSelectedItem
selectedItemBackgroundColor
selectedItemTextColor
dropdownSeparatorStyle
selectedIndex
selectedItem
class MyViewController: UIViewController, SwiftDropdownDelegate { ... dropdown.delegate = self ... func dropdownItemSelected(index: Int, item: String) {}
We welcome all contributions. If you found a bug, feel free to open an issue. If you want to contribute, submit a pull request.
SwiftDropdown is developed by Giuseppe Bruno.
SwiftDropdown is released under the MIT license. See LICENSE for details.
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
SwiftDropdown
A simple fully customizable dropdown.
Installation
Swift Package Manager
The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the
swift
compiler.Once you have your Swift package set up, add SwiftDropdown to the
dependencies
value of yourPackage.swift
.Usage
Add a
UIView
from the Storyboard and subclass asSwiftDropdown
or create aSwiftDropdown
view from code.That’s it.
Customization
You can customize the Dropdown as follow:
Dropdown box
boxBackgroundColor
: Dropdown box background color. Default: whiteplaceholderFont
: Dropdown box text font. Default: System fontplaceholderColor
: Dropdown box text color. Default: blackarrowImage
: Dropdown arrow image.arrowPosition
: Arrow position. Default: rightcornerRadius
: Box and dropdown corner radiusborderWidth
: Box and dropdown border width. Default: 1borderColor
: Box and dropdown border color. Default: blackdisableArrowAnimation
: Disable arrow animation. Default: trueDropdown
dropdownHeight
: Dropdown height. By default will be calculated automatically.itemsRowHeight
: Dropdown items row height. Default: 44itemsFont
: Dropdown items text font. Default: System fontitemsTextColor
: Dropdown items text color. Default: blackdisableTapToDismiss
: Disable tap outside the dropdown to dismiss itself. Default: falsedropdownExtraSpace
: Space between the box and the dropdown. Default: 8itemsBackgroundColor
: Dropdown items background color. Default: whiteshowSelectedItemCheckmark
: Show checkmark for selected item. Default: truecheckmarkColor
: Selected item checkmark color. Default: system bluehighlightSelectedItem
: Highlight selected item. Default: falseselectedItemBackgroundColor
: Selected item background color. Default: system blueselectedItemTextColor
: Selected item text color. Default: whitedropdownSeparatorStyle
: Dropdown item separator styleAPI
selectedIndex
: Current selected index. If setted, the dropdown will show the item as selected.selectedItem
: Current selected itemDelegate
Contributing
We welcome all contributions. If you found a bug, feel free to open an issue. If you want to contribute, submit a pull request.
Show your support 💪
Credits
SwiftDropdown is developed by Giuseppe Bruno.
License
SwiftDropdown is released under the MIT license. See LICENSE for details.