Giter Club home page Giter Club logo

expandingmenu's Introduction

ExpandingMenu

CI Status Version License Platform

demo

ExpandingMenu is written in Swift.

Requirements

  • iOS 8.0+
  • Xcode 10.0+
  • Swift 3.x+

Installation

CocoaPods

You can install CocoaPods with the following command:

$ gem install cocoapods

To integrate ExpandingMenu 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 'ExpandingMenu', '~> 0.4'
end

Then, run the following command:

$ pod install

Carthage

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

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

github "monoqlo/ExpandingMenu" ~> 0.4

Run carthage update to build the framework and drag the built ExpandingMenu.framework into your Xcode project.

Manually

  1. Download and drop /ExpandingMenufolder in your project.
  2. Congratulations!

Usage

import ExpandingMenu

let menuButtonSize: CGSize = CGSize(width: 64.0, height: 64.0)
let menuButton = ExpandingMenuButton(frame: CGRect(origin: CGPoint.zero, size: menuButtonSize), image: UIImage(named: "chooser-button-tab")!, rotatedImage: UIImage(named: "chooser-button-tab-highlighted")!)
menuButton.center = CGPoint(x: self.view.bounds.width - 32.0, y: self.view.bounds.height - 72.0)
view.addSubview(menuButton)

let item1 = ExpandingMenuItem(size: menuButtonSize, title: "Music", image: UIImage(named: "chooser-moment-icon-music")!, highlightedImage: UIImage(named: "chooser-moment-icon-music-highlighted")!, backgroundImage: UIImage(named: "chooser-moment-button"), backgroundHighlightedImage: UIImage(named: "chooser-moment-button-highlighted")) { () -> Void in
            // Do some action
        }

・・・

let item5 = ExpandingMenuItem(size: menuButtonSize, title: "Sleep", image: UIImage(named: "chooser-moment-icon-sleep")!, highlightedImage: UIImage(named: "chooser-moment-icon-sleep-highlighted")!, backgroundImage: UIImage(named: "chooser-moment-button"), backgroundHighlightedImage: UIImage(named: "chooser-moment-button-highlighted")) { () -> Void in
            // Do some action
        }
        
menuButton.addMenuItems([item1, item2, item3, item4, item5])

Customize

ExpandingMenuButton

// Bottom dim view
menuButton.bottomViewColor = UIColor.redColor()
menuButton.bottomViewAlpha = 0.2

// Whether the tapped action fires when title are tapped
menuButton.titleTappedActionEnabled = false

// Menu item direction
menuButton.expandingDirection = .Bottom
menuButton.menuTitleDirection = .Right

// The action when the menu appears/disappears
menuButton.willPresentMenuItems = { (menu) -> Void in
    print("MenuItems will present.")
}

menuButton.didPresentMenuItems = { (menu) -> Void in
    print("MenuItems will present.")
}
        
menuButton.willDismissMenuItems = { (menu) -> Void in
    print("MenuItems dismissed.")
}

menuButton.didDismissMenuItems = { (menu) -> Void in
    print("MenuItems will present.")
}

// Expanding Animation
menuButton.expandingAnimations = [] // No animation

menuButton.expandingAnimations = CustomAnimationOptions.all.symmetricDifference(.menuButtonRotate)

// Folding Animation
menuButton.foldingAnimations = .all

menuButton.foldingAnimations = [.MenuItemMoving, .MenuItemFade, .MenuButtonRotation]

ExpandingMenuItem

// Title
item.title = "text"
item.titleColor = UIColor.redColor()

// Title margin to menu item
item.titleMargin = 4

Author

monoqlo, [email protected]

License

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

expandingmenu's People

Contributors

kamrankhan-chilindo avatar kamrankhan07 avatar lfarah avatar lukaz32 avatar maryom avatar monoqlo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

expandingmenu's Issues

Remove Items from button

Hi

How would you implement remove all items from a button so I can reuse button for different use cases?

Thanks!

App crashes after manual setup for 4.2 support

I had the old version of code using the manual setup and now I have updated it with support 4.2
I have just replaced old code in ExpandingMenuButton.swift and ExpandingMenuItem.swift with the new code.

And the app crashes on line :

self.expandingSoundPath = Bundle(url: Bundle(for: ExpandingMenuButton.classForCoder()).url(forResource: "ExpandingMenu", withExtension: "bundle")!)?.path(forResource: "expanding", ofType: "caf")

Error is >> Fatal error: Unexpectedly found nil while unwrapping an Optional value

@monoqlo Kindly revert soon as I had updated the code to release my app with newer version.

Thank you.

Pod version 0.3 is not installing

Hi, I'm trying to add pod 'ExpandingMenu', '~> 0.3' to my project but getting an error:

None of your spec sources contain a spec satisfying the dependency: ExpandingMenu (~> 0.3).

When I remove the version number, it always installs 0.2. My project is in Swift 3 so 0.2 asks me to convert. I'm guessing something is not up to date with your pod spec?

Thank you!

Typo In README.md Example Code

Typo In README.md Example Code

There is a small error in the example code in the README.md under "Customize" -> "ExpandingMenuButton".

exclusiveOr should be symmetricDifference in

menuButton.enabledExpandingAnimations = AnimationOptions.All.exclusiveOr(.MenuItemRotation)

Thank you for writing this library! 👍

Possible to change the font of titles?

I can't figure out where and how to edit the code to adjust the font of the menu items. How can that be done and could it be added to the project as an editable variable in the future?

Add support for Autolyout

It would be great if you could add support for Autolayout.

Currently I'm trying something like this, but it is not working with conditions you have made inside your code.

private func configureAutolayoutConstraints(buttonView: UIView, parentView: UIView){

        buttonView.translatesAutoresizingMaskIntoConstraints = false

        let bottomConstraint = NSLayoutConstraint(item: buttonView, attribute:
            .Bottom, relatedBy: .Equal, toItem: parentView, attribute: .Bottom, multiplier: 1.0, constant: -30)

        parentView.addConstraint(bottomConstraint)


        let trailingConstraint = NSLayoutConstraint(item: buttonView, attribute:
            .Trailing, relatedBy: .Equal, toItem: parentView, attribute: .Trailing, multiplier: 1.0, constant: -30)
        parentView.addConstraint(trailingConstraint)



        let widthConstraint = NSLayoutConstraint(item: buttonView, attribute:
            .Width , relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute, multiplier: 1.0, constant: 80)

        parentView.addConstraint(widthConstraint)

        let heightConstraint = NSLayoutConstraint(item: buttonView, attribute:
            .Height , relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute, multiplier: 1.0, constant: 80)

        parentView.addConstraint(heightConstraint)

    }

Change menu item image on tap

Hello,

I'm trying to change the menu item image after tapping on it, but I can't seem to find a way to do it. Is it possible to do that? or is there any workaround that I should do to make it happen?

Thanks a lot.

Handle rotation well

This control doesn't work well with rotation for several reasons

a) The coordinates for it are hardcoded (I think it should support autolayout, which is raised by another person already)
b) The control should update some internal things (like a frame of bottom alpha view) when parent view is rotated.

Size is broken add Spacing parameter

The size of the main button (and it's inherited items) are not being honored. They, always stay 50px or so even when I set the Rect to 90x90.

Also, how could we add a custom spacing value, the more items I add the less separation there should be between them. Perhaps take into account a maxHeight.

Thanks, great work!

How to use as a UIBarButtonItem

How can I use ExpandingMenu as a UIBarButtonItem? When I set it as a right UIBarButtonItem through custom view, when expanded it rises up off of the screen and doesn't allow me to touch around. I then tried to add it to the view's window, and when opened up constrained by auto layout, opening it up the options were completely off of the screen far to the right. How can I use the Expanding Menu as a "bar button" or at least make it seem as if it is a right bar button giving the user options?

Cocoapods install issue

Hello, I have an issue while installing the pod. When I try to install the cocoapods, I get the following error:

[!] /usr/bin/git clone https://github.com/monoqlo/ExpandingMenu.git /var/folders/ls/g04xq0yn4nj89q29xynn9h2w0000gn/T/d20160621-11755-4i7chp --template= --single-branch --depth 1 --branch 0.1.3

Cloning into '/var/folders/ls/g04xq0yn4nj89q29xynn9h2w0000gn/T/d20160621-11755-4i7chp'...
fatal: unable to access 'https://github.com/monoqlo/ExpandingMenu.git/': Could not resolve host: github.com

Do you have any idea how to solve this issue?

Thank you.

Best wishes,
Murat Yaşar

Handle rotation well

This control doesn't work well with rotation for several reasons

a) The coordinates for it are hardcoded (I think it should support autolayout, which is raised by another person already)
b) The control should update some internal things (like a frame of bottom alpha view) when parent view is rotated.

make it customizable

Hi - first of all: Great project - it would really help me in my project.

It would be great if you could make it more customizable for the end users. E.g. I would like to have a transparent bottomViewColor and I would like to change the color of the menu titles.

What do you think?

Expanding Position Menu Button

Hi

How can I change the menu button when the menu expanded ?

When folding position, button image will be plus.
When expanding position, button image will be cross.

Can I stop rotation of subitems?

@monoqlo
Thank you for your help.

I have received your message for fix background color.

I need one to use it.
Can you add option to stop ration of sub menus? (+ button is ok).

Make it appear down instead of up

Hi

Possible to change the appearance of the sub button items downwards instead of upwards?

That is, the main button is at the top and when clicked, buttons appear in one column from top..

Issues with xcode 10/Swift 4.2

Hello,

I just updated to Xcode 10 beta, and I am seeing 41 issues that prevent be from building the project.
In Xcode 9.4.1 with a deployment target of iOS 11.4, I'm not seeing these issues.

Do you have any plans on updating this module, or do I need to jump ship?

Thanks,
David

Typo Error in "item1" Highlighted Image is Pointed to Place in Sample Project

Line 38. Just replace the image file name from:

let item1 = ExpandingMenuItem(size: menuButtonSize, title: "Music", image: UIImage(named: "chooser-moment-icon-music")!, highlightedImage: UIImage(named: "chooser-moment-icon-place-highlighted")!, backgroundImage: UIImage(named: "chooser-moment-button"), backgroundHighlightedImage: UIImage(named: "chooser-moment-button-highlighted")) { () -> Void in

to

let item1 = ExpandingMenuItem(size: menuButtonSize, title: "Music", image: UIImage(named: "chooser-moment-icon-music")!, highlightedImage: UIImage(named: "chooser-moment-icon-music-highlighted")!, backgroundImage: UIImage(named: "chooser-moment-button"), backgroundHighlightedImage: UIImage(named: "chooser-moment-button-highlighted")) { () -> Void in

double line

hi,
how can i set the button title to be 2 lines?

Animation option not found

when I installed Xcode 10 and swift 4.2 this issue appeared

Pods/ExpandingMenu/ExpandingMenu/Classes/ExpandingMenuButton.swift:78:62: Type 'UIView.AnimationOptions' has no member 'Default'

Closing The Menu

You can't close the menu using the centerButton when the menu is expanded.

If you click the 'centerButton' while the menu is open, it just opens another menu on top of the current open menu. This makes absolutely zero sense. When the menu is open, the centerButton action should fold the menu, not open another one.

Can't run carthage update build

carthage update --platform iOS --verbose
*** Fetching ExpandingMenu
*** Checking out ExpandingMenu at "0.3.1"
*** Skipped building ExpandingMenu due to the error:
Dependency "ExpandingMenu" has no shared framework schemes for any of the platforms: iOS

Margin between menu button and first item

Hello, awesome work on the menu.

I have an issue with the margin between the menu button and the first item. This gap is causing a menu item to be off the screen.
Suggestions?
Thank you
IMG_C1377ED6DC2D-1

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.