Git Product home page Git Product logo

btnavigationdropdownmenu's Introduction

alt tag

Pod Version License: MIT Language

Introduction:

The elegant dropdown menu, written in Swift, appears underneath navigation bar to display a list of related items when a user click on the navigation title.

alt tag

Installation:

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

use_frameworks!
pod 'BTNavigationDropdownMenu'

Go ahead and import BTNavigationDropdownMenu into your own Swift files

import BTNavigationDropdownMenu

Note: This library mainly supports for Xcode 7, Swift 2.0 and embedded frameworks. For older versions of XCode, use branch swift-1.2

Usage:

Instantiating

Start by creating an Array that contains strings as elements of dropdown list:

let items = ["Most Popular", "Latest", "Trending", "Nearest", "Top Picks"]

Create a new instance of BTNavigationDropdownMenu:

let menuView = BTNavigationDropdownMenu(navigationController: self.navigationController, title: items.first!, items: items)

Set title of navigation bar as menuView:

self.navigationItem.titleView = menuView

Call BTNavigationDropdownMenu closure to get the index of selected cell:

menuView.didSelectItemAtIndexHandler = {[weak self] (indexPath: Int) -> () in
            println("Did select item at index: \(indexPath)")
            self.selectedCellLabel.text = items[indexPath]
}

Use menuView.show() or menuView.hide() if you want to show or hide dropdown menu manually.

Use menuView.isShown (Boolean type) property to check showing state of dropdown menu.

Use menuView.toggle to toogle dropdown dropdown menu shown/hide.

Customization

Once you have assigned the items and frame for dropdown menu, you can custom the look and the feel of menu. You can override these properties for your favor:

cellHeight - The height of the cell. Default is 50

cellBackgroundColor - The color of the cell background. Default is whiteColor()

cellSeparatorColor - The color of the cell separator. Default is darkGrayColor()

cellTextLabelColor - The color of the text inside cell. Default is darkGrayColor()

cellTextLabelFont - The font of the text inside cell. Default is HelveticaNeue-Bold, size 19

cellTextLabelAlignment - The alignment of the text inside cell. Default is .Left

cellSelectionColor - The color of the cell when the cell is selected. Default is lightGrayColor()

keepSelectedCellColor - The boolean value that decides if selected color of cell is visible when the menu is shown. Default is false

checkMarkImage - The checkmark icon of the cell.

animationDuration - The animation duration of showing/hiding menu. Default is 0.5s

bounceOffset - The value of bounce offset. Default is 10

arrowImage - The arrow next to navigation title

arrowPadding - The padding between navigation title and arrow. Default is 15

maskBackgroundColor - The color of the mask layer. Default is blackColor()

maskBackgroundOpacity - The opacity of the mask layer. Default is 0.3

Requirement

  • iOS 8.0+ (CocoaPods with Swift support will only work on iOS 8.0+. Alternatively, you will have to import library manually to your project)
  • Xcode 7.0+, Swift 2.0+

Changelog

See the CHANGELOG for details

License

BTNavigationDropdownMenu is available under the MIT License. See the LICENSE for details.

btnavigationdropdownmenu's People

Contributors

phambatho avatar tuanphung avatar rickerbh avatar ninjarz avatar naoyashiga avatar bclymer avatar justindhill avatar frostover avatar readmecritic avatar ilyailya avatar

Watchers

Michael.Yang avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.