GithubHelp home page GithubHelp logo

pablo-merino / azdropdownmenu Goto Github PK

View Code? Open in Web Editor NEW

This project forked from azuritul/azdropdownmenu

0.0 3.0 0.0 111 KB

A simple dropdown menu component for iOS written in Swift

Home Page: http://azuritul.github.io/AZDropdownMenu

License: MIT License

Ruby 3.74% Swift 62.60% Objective-C 1.83% Shell 31.83%

azdropdownmenu's Introduction

AZDropdownMenu

CI Status Version License Platform Language

AZDropdownMenu is a simple dropdown menu component that supports Swift.

Screenshots

Code used in the screencast are included in the bundled sample project.

cast

Usage

To run the example project, clone the repo with git clone https://github.com/Azuritul/AZDropdownMenu.git, and run pod install from the Example directory first.

Requirements

  • iOS 8 or above
  • Xcode 7 or above
  • Swift 2.0

Installation

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

use_frameworks!
pod 'AZDropdownMenu'

Usage

Declare an array of texts that are served as the item in the menu.

let titles = ["Action 1", "Action 2", "Action 3"]

Then pass the array to the initializer

let menu = AZDropdownMenu(titles: leftTitles )

Calling public func showMenuFromView(view:UIView) can then show the menu.

The handler public var cellTapHandler : ((indexPath:NSIndexPath) -> Void)? would be called when menu item is tapped. So place code in here to do whatever you want. For example

menu.cellTapHandler = { [weak self] (indexPath: NSIndexPath) -> Void in
self?.navigationController?.pushViewController(controller, animated:true)
}

Create menu with icons

Pass in a AZDropdownMenuItemData in the initializer: public init(dataSource:[AZDropdownMenuItemData]) and you are good to go.

Do take a look at the sample project in this repository to get more usage of the library.

Configurable options

Currently AZDropdownMenu can be customized with the following properties. More will come in the future.

  • itemHeight Row height of the menu item. Default is 44.
  • itemColor The background color of the menu item. Default is white.
  • itemFontColor The text color of the menu item. Default is black.
  • itemFontSize Font size of the menu item. Default is 14.0
  • itemFont Font used in the menu. Default is 'Helvetica'
  • itemAlignment The alignment of the menu item. Default is left-aligned.
  • itemSelectionColor The background color of the menu item while it is tapped. Default is gray.
  • overlayAlpha The transparency for the background overlay. Default is 0.5
  • overlayColor Color for the background overlay. Default is black.
  • menuSeparatorStyle The separator of the menu. Default is single line.
  • menuSeparatorColor The color of the separator. Default is light gray.
  • itemImagePosition The position of image in the menu. Can be positioned before or after the text. Default is .Prefix.

Version

  • 1.0.0
    • Added itemImagePosition option, now can configure the icon position.
    • Changed icon sets and its corresponding location in the sample project.
    • Modified sample project's appearance a little bit.
    • Modified sample project's structure.
    • Added CHANGELOG.md
  • 0.6.1
    • Update readme
  • 0.6.0
    • Now can use icons in the menu.
    • Added configuration options: menuSeparatorColor, itemFont
  • 0.5.3
    • Now can configure item's background color while tapped

Credit

Author

Chris Wu (Azuritul), [email protected]

Contribute

  1. Fork the repo
  2. Create your own branch with names that are easy to understand, e.g: feature/xxx-feature
  3. Commit changes
  4. Push branch to origin or whatever repo your name is: git push origin feature/xxx-feature
  5. Submit a pull request, compare against develop branch in the upstream repo and ensure there is no conflict between the two.

License

AZDropdownMenu is available under the MIT license. See the LICENSE file for more info.

azdropdownmenu's People

Contributors

azuritul avatar pablo-merino avatar

Watchers

 avatar  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.