Skip to content

idapgroup/SimpleDropdown

Repository files navigation

SimpleDropdown

This is a simple dropdown that can be easily integrated into your app layout and customize to suit your design.

So you just need to import this library:

    import SimpleDropdown

create a dropdown instance in your code:

    let dropdownView = DropdownView(options: ["Option 1", "Option 2", "Option 3"], customCellType: CustomDropdownCell.self, customCellIdentifier: "cell", customHeaderView: CustomDropdownView())

make some constraints and use it.

You can also change the menu cells (UITableViewCell) to your own custom ones and configure them through the configurator function:

    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.dropdownView.cellConfigurator = { cell, option in
            if let customCell = cell as? CustomDropdownCell {
               customCell.configure(
                   with: option,
                   icon: UIImage(systemName: "star"),
                   subtitle: "Subtitle for \(option)"
               )
           }
        }
    }

You can do the same with the header (UIView):

    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.dropdownView.headerConfigurator = { customView, option in
            if let view = view as? CustomDropdownView {
                view.set(title: option)
            }
        }
    }

To remove or change the selection in the dropdown from the outside in your code you can call:

    self.dropdownView.updateCurrentOption(option: "Some placeholder")

The header configurator is subscribed to the current option and will update the header immediately.

Снимок экрана 2024-09-02 в 20 08 01

Requirements

iOS 15+. Swift 5.5.

Installation

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

pod "SimpleDropdown"

SimpleDropdown is available through Carthage. To install it, simply add the following line to your Cartfile:

github "idapgroup/SimpleDropdown"

License

SimpleDropdown is available under the New BSD license. See the LICENSE file for more info.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •