An elegant dropdown for iOS written in Swift.

Related tags

Menu UIDropDown
Overview

UIDropDown

An elegant dropdown for iOS written in Swift.

Overview

UIDropDown allows you to pick an option in a table just like dropdowns in web. It contains 3 differents animations to present the options table and can be modified in many ways.

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate UIDropDown into your Xcode project using CocoaPods, specify it in your Podfile:

target '<Your Target Name>' do
    pod 'UIDropDown'
end

Then, run the following command:

$ pod install

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate UIDropDown into your Xcode project using Carthage, specify it in your Cartfile:

github "igongora/UIDropDown"

Run carthage update to build the framework and drag the built DropDown.framework into "Embedded binaries".

Usage

Use UIDropDown it's as easy as set the array of strings you want to show and a placeholder

drop = UIDropDown(frame: CGRect(x: 0, y: 0, width: 200, height: 30))
drop.center = CGPoint(x: self.view.frame.midX, y: self.view.frame.midY)
drop.placeholder = "Select your country..."
drop.options = ["Mexico", "USA", "England", "France", "Germany", "Spain", "Italy", "Canada"]
drop.didSelect { (option, index) in
                     self.label.text = "You just select \(option) at index: \(index)"
                     print("You just select: \(option) at index: \(index)")
               }
self.view.addSubview(drop) 

The "didSelect" method will return the string and index selected

drop.didSelect { (option, index) in
                     self.label.text = "You just select \(option) at index: \(index)"
                     print("You just select: \(option) at index: \(index)")
               }

Requirements

  • iOS 8.0+
  • Xcode 8.0+
  • Swift 3+

Author

Isaac Gongora, [email protected]

License

UIDropDown is available under the MIT license

You might also like...
A simple side menu for iOS written in Swift.
A simple side menu for iOS written in Swift.

ENSwiftSideMenu A lightweight flyover side menu component for iOS with the UIDynamic's bouncing animation, UIGestures and UIBlurEffect. Allows you to

iOS Interactive Side Menu written in Swift.
iOS Interactive Side Menu written in Swift.

Interactive Side Menu A customizable, interactive, auto expanding and collapsing side menu for iOS written in Swift. Here are some of the ways Interac

ExpandingMenu is menu button for iOS written in Swift.
ExpandingMenu is menu button for iOS written in Swift.

ExpandingMenu ExpandingMenu is written in Swift. Requirements iOS 8.0+ Xcode 10.0+ Swift 3.x+ Installation CocoaPods You can install CocoaPods with th

A side menu controller written in Swift for iOS
A side menu controller written in Swift for iOS

Description SideMenuController is a custom container view controller written in Swift which will display the main content within a center panel and th

Beautiful iOS side menu library with parallax effect. Written in Swift
Beautiful iOS side menu library with parallax effect. Written in Swift

AKSideMenu AKSideMenu is a double side menu library with parallax effect. Example Project See the contained examples to get a sample of how AKSideMenu

iOS Slide Menu Controller. It is written in pure swift.
iOS Slide Menu Controller. It is written in pure swift.

SlideMenuController Requirements iOS 9+ Installation SlideMenuController is available through CocoaPods. To install it, simply add the following line

A Slide Menu, written in Swift, inspired by Slide Menu Material Design
A Slide Menu, written in Swift, inspired by Slide Menu Material Design

Swift-Slide-Menu (Material Design Inspired) A Slide Menu, written in Swift 2, inspired by Navigation Drawer on Material Design (inspired by Google Mat

Animated top menu for UITableView / UICollectionView / UIScrollView written in Swift
Animated top menu for UITableView / UICollectionView / UIScrollView written in Swift

Persei Animated top menu for UITableView / UICollectionView / UIScrollView written in Swift! Made in Yalantis. Check this project on Dribbble Check th

UIKit drop down menu, simple yet flexible and written in Swift
UIKit drop down menu, simple yet flexible and written in Swift

DropDownMenuKit DropDownMenuKit is a custom UIKit control to show a menu attached to the navigation bar or toolbar. The menu appears with a sliding an

Comments
  • Can not be selected when added inside UICollectionViewCell

    Can not be selected when added inside UICollectionViewCell

    Hello,

    When I added UIDropDown inside my UICollectionViewCell. It can not be selected. It doesn't response to user tap or click.

    class MyCell: UICollectionViewCell {
        override init(frame: CGRect) {
            super.init(frame: frame)
            setupViews()
        }
        required init?(coder aDecoder: NSCoder) {
            fatalError("init(coder:) has not been implemented")
        }
    
        setupViews(){
            drop = UIDropDown(frame: CGRect(x: 0, y: 0, width: 80, height: 30))
            drop.center = CGPoint(x: 0, y: 0)
            drop.placeholder = "select your country"
            drop.options = ["Mexico", "USA", "England", "France", 
            drop.didSelect { (option, index) in
                print("You just select: \(option) at index: \(index)")
            }
            drop.tableHeight = 200
            drop.hideOptionsWhenSelect = true
            drop.animationType = UIDropDownAnimationType(rawValue: 0)!
            addSubview(drop)
        }
    }
    

    I've used UIDropDown in my other project. It works really great. Thanks you! But I don't know what I'm doing wrong in this case.

    opened by johnyluyte 2
  • What happened to selectedIndex and selectDropDownOptionManually?

    What happened to selectedIndex and selectDropDownOptionManually?

    I used these two functions a lot (hundreds of times throughout my projects) but it seems that the functions are no longer available? I can't find a reasonable solution or workaround meaning that my project no longer work.

    Why were these functions pulled?

    Were they replaced with something?

    Thanks

    opened by AussieSam 0
  • Text alignment issue

    Text alignment issue

    I believe that there is an issue which makes the text alignment dependent on the "View As" selection made it xCode. This means that it will not be possible to make the drop down appear correctly on both an iPhone and iPad at the same time.

    To clarify, this is only an issue when you specify leading and trailing widths to say superview. If instead, you were to center the UIDropdown on the x axis and explicitly specify the width then you would have no issue, but you would have a small dropdown on an iPad

    The below change appears to have fixed the issue, I have used screenSize.width rather than self.frame.width

        fileprivate func setup() {
        let screenSize: CGRect = UIScreen.main.bounds
        let screenWidth = screenSize.width
        let screenHeight = screenSize.height
        title = UILabel(frame: CGRect(x: 0,
                                      y: 0,
                                      width: (screenWidth-self.frame.height),
                                      height: self.frame.height))
    
        title.textAlignment = .center
         print("\(self.frame.width)")
        print("\(screenWidth)")
        self.addSubview(title)
    

    There may be a way to specify the object width when the dropdown is set up. I tried but it didnt affect the actual size of self.frame.width inside the UIDropDown class

    dropDown1.frame = CGRect(x: 0, y:0, width: self.view.frame.width, height: self.view.frame.height)
        dropDown1.center = CGPoint(x: self.view.frame.midX, y: self.view.frame.midY)
    

    If there is a way to use your original code but specify the width so that self.frame.width is not dependent on the Storyboard "view as" device type then could you please tell me how to do that?

    opened by AussieSam 0
Owner
Isaac Gongora
Isaac Gongora
✨ Awesome Dropdown menu for iOS with Swift 5.0

The eligible dropdown menu for iOS, written in Swift 5, appears dropdown menu to display a view of related items when a user click on the dropdown menu. You can customize dropdown view whatever you like (e.g. UITableView, UICollectionView... etc)

Kyle Yi 1.3k Dec 26, 2022
🔻 Dropdown Menu for iOS with many customizable parameters to suit any needs

MKDropdownMenu Dropdown Menu for iOS with many customizable parameters to suit any needs. Inspired by UIPickerView. Installation CocoaPods MKDropdownM

Max Konovalov 531 Dec 26, 2022
Fantastic dropdown in Swift

Dropdowns ❤️ Support my app ❤️ Push Hero - pure Swift native macOS application to test push notifications Quick Access - Organise files in the Mac men

Khoa 307 Oct 17, 2022
A simple dropdown menu component for iPhone

AZDropdownMenu AZDropdownMenu is a simple dropdown menu component that supports Swift. Screenshots Code used in the screencast are included in the bun

Wu 194 Nov 14, 2022
JNDropDownMenu - Easy to use TableView style dropdown menu.

Overview Swift version of https://github.com/dopcn/DOPDropDownMenu Easy to use TableView style dropdown menu. Setup The only thing you

Javal Nanda 65 Jun 27, 2021
This is a simple Mac Catalyst example showcasing how to build a dropdown menu toolbar button using AppKit.

CatalystToolbarMenuButton This is a simple Mac Catalyst example showcasing how to build a dropdown menu toolbar button using AppKit. There are ways to

Steven Troughton-Smith 24 Dec 8, 2022
Simple and Elegant Drop down menu for iOS 🔥💥

SwiftyMenu is simple yet powerfull drop down menu component for iOS. It allow you to have drop down menu that doesn't appear over your views, which gi

Karim Ebrahem 502 Nov 29, 2022
⭕️ CircleMenu is a simple, elegant UI menu with a circular layout and material design animations. Swift UI library made by @Ramotion

CIRCLE MENU Simple, elegant UI menu with a circular layout and material design animations We specialize in the designing and coding of custom UI for M

Ramotion 3.4k Dec 29, 2022
iOS Slide Menu View based on Google+, iQON, Feedly, Ameba iOS app. It is written in pure swift.

SlideMenuControllerSwift iOS Slide View based on iQON, Feedly, Google+, Ameba iPhone app. Installation CocoaPods pod 'SlideMenuControllerSwift' Carth

Yuji Hato 3.3k Dec 29, 2022
Alejandro Piguave 24 Dec 30, 2022