• Stars
    star
    133
  • Rank 272,600 (Top 6 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Dropdown menu for NavigationController in Swift, also support Dropup Menu

teambition

Carthage Compatible CocoaPods Compatible

DropdownMenu is a dropdown menu for navigationController in Swift, It can be associated in any place if have a navigationController

Features

  • Dropdown Menu
  • Dropup Menu

Surpport cell type

  • Only text cell
  • Image and text cell
  • Highlight cell
  • Selected cell
  • Detail accessory cell

Requirements

  • iOS 8.0
  • Xcode 7.3+

Communication

Installation

**Embedded frameworks require a minimum deployment target of iOS 8

CocoaPods

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

$ gem install cocoapods

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

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'TBDropdownMenu'
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 DropdownMenu into your Xcode project using Carthage, specify it in your Cartfile:

github "teambition/DropdownMenu"

Run carthage update to build the framework

At last, you need to set up your Xcode project manually to add the DropdownMenu framework.

On your application targets’ “General” settings tab, in the “Linked Frameworks and Libraries” section, drag and drop each framework you want to use from the Carthage/Build folder on disk.

On your application targets’ “Build Phases” settings tab, click the “+” icon and choose “New Run Script Phase”. Create a Run Script with the following content:

 /usr/local/bin/carthage copy-frameworks

and add the paths to the frameworks you want to use under “Input Files”:

 $(SRCROOT)/Carthage/Build/iOS/DropdownMenu.framework

For more information about how to use Carthage, please see its project page

Usage

Import framework to your class

Cocoapods:

import TBDropdownMenu

Carthage:

import DropdownMenu

DropdownMenu

Add code for your action

Without Section
func showMenu(sender: UIBarButtonItem) {
        let item1 = DropdownItem(title: "NO Image")
        let item2 = DropdownItem(image: UIImage(named: "file")!, title: "File")
        let item3 = DropdownItem(image: UIImage(named: "post")!, title: "Post", style: .Highlight)
        let item4 = DropdownItem(image: UIImage(named: "post")!, title: "Event", style: .Highlight, accessoryImage: UIImage(named: "accessory")!)

        let items = [item1, item2, item3, item4]
        let menuView = DropdownMenu(navigationController: navigationController!, items: items, selectedRow: selectedRow)
        menuView.delegate = self
        menuView.showMenu()
    }
With Section
 @IBAction func showMenu(_ sender: UIBarButtonItem) {
        let item1 = DropdownItem(title: "NO Image")
        let item2 = DropdownItem(image: UIImage(named: "file")!, title: "File")
        let item3 = DropdownItem(image: UIImage(named: "post")!, title: "Post", style: .highlight)
        let item4 = DropdownItem(image: UIImage(named: "post")!, title: "Event", style: .highlight, accessoryImage: UIImage(named: "accessory")!)
        
        let section0 = DropdownSection(sectionIdentifier: "Teambition", items: [item1, item2])
        let section1 = DropdownSection(sectionIdentifier: "Space", items: [item3, item4])

        let menuView = DropdownMenu(navigationController: navigationController!, sections: [section0, section1], selectedIndexPath: selectedIndexPath)
        menuView?.delegate = self
        menuView?.showMenu()
    }

Handle delegate

extension ViewController: DropdownMenuDelegate {
    func dropdownMenu(dropdownMenu: DropdownMenu, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        print("DropdownMenu didselect \(indexPath.row)")
    }
}

DropupMenu

Add code for your action

@IBAction func dropUpAction(_ sender: UIBarButtonItem) {
        let item1 = DropdownItem(title: "NO Image")
        let item2 = DropdownItem(image: UIImage(named: "file")!, title: "File")
        let item3 = DropdownItem(image: UIImage(named: "post")!, title: "Post", style: .highlight)
        let item4 = DropdownItem(image: UIImage(named: "post")!, title: "Event", style: .highlight, accessoryImage: UIImage(named: "accessory")!)
        
        let data = [item1, item2, item3, item4]
        items = [data]
        let menuView = DropUpMenu(items: data, selectedRow: 0, bottomOffsetY: self.tabBarController?.tabBar.frame.height ?? 0)
        menuView.delegate = self
        menuView.showMenu()
    }

Handle delegate

extension ViewController: DropUpMenuDelegate {
    func dropUpMenu(_ dropUpMenu: DropUpMenu, didSelectRowAt indexPath: IndexPath) {
        let alertConroller = UIAlertController(title: "Nice", message: "DropUpMenu didselect \(indexPath.row) text:\(items[indexPath.section][indexPath.row].title)", preferredStyle: .alert)
        let okAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
        alertConroller.addAction(okAction)
        present(alertConroller, animated: true) {
            print("Display success")
        }
    }
    
    func dropUpMenuCancel(_ dropUpMenu: DropUpMenu) {
        print("select cancel")
    }
}

for detail, Please check the demo

License

DropdownMenu is released under the MIT license.

More Repositories

1

then.js

[快照]史上最快,与 node callback 完美结合的异步流程控制库!
JavaScript
573
star
2

gear

A lightweight, composable and high performance web service framework for Go.
Go
551
star
3

teambition-sdk

Isomorphic JavaScript SDK for Teambition APIs
TypeScript
433
star
4

rrule-go

Go library for working with recurrence rules for calendar dates.
Go
313
star
5

TBEmptyDataSet

An extension of UITableView/UICollectionView's super class, it will display a placeholder emptyDataSet when the data of tableView/collectionView is empty.
Swift
206
star
6

Hire

Working With Great People
200
star
7

gulp-sequence

Run a series of gulp tasks in order
JavaScript
195
star
8

gulp-ssh

SSH and SFTP tasks for gulp
JavaScript
183
star
9

merge2

Merge multiple streams into one stream in sequence or parallel (~119M/month downloads).
JavaScript
171
star
10

snapper-core

Teambition push messaging service, backed by redis.
JavaScript
115
star
11

webapp-solutions

Try to collect anwsers on problems we encounter in Web Apps
113
star
12

ReactiveDB

Reactive ORM for Lovefield
TypeScript
105
star
13

jsonrpc-lite

Parse and Serialize JSON-RPC2 messages in node.js, or browser.
JavaScript
95
star
14

ratelimiter-go

The fastest abstract rate limiter, base on go-redis/redis.
Go
93
star
15

RRuleSwift

Swift rrule library for working with recurrence rules of calendar dates.
JavaScript
90
star
16

swaggo

Convert Go annotations to Swagger Documentation (version 2.0)
Go
68
star
17

SegmentedControl

A highly customizable segmented control for iOS applications.
Swift
64
star
18

HanziPinyin

A lightweight Swift library supporting convertion between Chinese(both Simplified and Tranditional) characters and Pinyin.
Swift
57
star
19

WebBrowser

A web browser using WebKit and written in Swift for iOS apps.
Swift
55
star
20

timed-queue

Distributed timed job queue, backed by Redis.
JavaScript
50
star
21

pdfviewer

PDF Viewer using Mozilla PDF JS
JavaScript
49
star
22

AMRAudioSwift

A useful tool to encode or decode audio between AMR and WAVE.
Swift
38
star
23

CardStyleTableView

An extension of UITableView and UITableViewCell which displays a card style view in grouped tableView, similar to the system's tableView before iOS 7.
Swift
32
star
24

trie-mux

A minimal and powerful trie based url path router (or mux) for Go.
Go
27
star
25

Pocket-Node-SDK

Headless Node.js SDK for integrating with [Pocket](http://getpocket.com/)
CoffeeScript
23
star
26

TB-Icons

A classified icons set that consists of a part of Material Design icons and some original icons by TB-UI team. Available in Icon Fonts and SVG Symbols.
Stylus
23
star
27

limbo

Factory/Loader of mongoose
CoffeeScript
17
star
28

json-mask-go

👺 JSON mask for Go
Go
10
star
29

tb-i18n-loader

i18n loader of teambition web for webpack
JavaScript
9
star
30

tws-auth

Node.js SDK of TWS (Teambition Web Service) client.
TypeScript
8
star
31

snapper-swift

Snapper-core client by Swift 2.0
Swift
8
star
32

node-teambition

JavaScript
7
star
33

redlimit

RedLimit is a redis-based distributed rate limit HTTP service, implemented with Rust.
Rust
7
star
34

tb-apps-sdk

Teambition API Bridge
TypeScript
7
star
35

teambition-node-sdk

teambition node sdk for server applications
TypeScript
6
star
36

WeChatSDK

Swift version of WeChat SDK.
Objective-C
5
star
37

node-chinese-finance-number

JavaScript
4
star
38

smart-limiter

Smart rate limiter middleware for express.
JavaScript
4
star
39

urbs-setting

Urbs 灰度平台灰度策略服务
Go
4
star
40

ilog

light-weight, smart and pure log module
JavaScript
3
star
41

teambition-java-sdk

teambition java sdk for server applications
Java
3
star
42

pipe-errors

Handle errors on piping streams and pipe error to the end.
JavaScript
3
star
43

i18n-middleware

An i18n middleware built for web apps.
CoffeeScript
2
star
44

grpclb

grpclb policy that consistent hash implemention, base on discovery systems like etcd, consul etc.
Go
2
star
45

teambition-server-sdk

TypeScript
2
star
46

gem-next

general entity manager next generation
TypeScript
2
star
47

tws-tcm

Node.js SDK of TWS (Teambition Web Service) cloud messaging service
TypeScript
1
star