GithubHelp home page GithubHelp logo

88oio / dlwidgetmenu Goto Github PK

View Code? Open in Web Editor NEW

This project forked from regexident/dlwidgetmenu

0.0 2.0 0.0 2.68 MB

Versatile solution for displaying widget menus. Easily adjustable with custom layouts and/or animations.

License: Other

Ruby 2.47% Objective-C 97.53%

dlwidgetmenu's Introduction

DLWidgetMenu

DLWidgetMenu is a versatile solution for displaying widget menus and can easily be extended with custom layouts and/or animations.

Preview

screenshot

Features

DLWidgetMenu comes with three built-in layouts:

  • DLWMLinearLayout
  • DLWMRadialLayout
  • DLWMSpiralLayout

DLWidgetMenu uses iOS7's spring animations (DLWMSpringMenuAnimator) by default, but can easily be provided with your own custom animations as well (by subclassing DLWMMenuAnimator).

DLWidgetMenu observes its menu items for these gesture recognizer events:

  • single tap
  • double tap
  • long press
  • pan
  • pinch

and forwards them directly to its delegate.

None of these events make DLWidgetMenu do anything by default.
The menu (by default) doesn't even open, when you tap it!

And it shouldn't.

DLWidgetMenu was specifically designed to keep you in full control over its behaviour. All it does is animating and layouting its menu items. Keeping you in total charge of what to do and when.

Assuming you do want DLWidgetMenu to open when single-tapped, all you need to do is implement this in your DLWMMenuDelegate:

- (void)receivedSingleTap:(UITapGestureRecognizer *)recognizer onItem:(DLWMMenuItem *)item inMenu:(DLWMMenu *)menu {
	if ([menu isClosedOrClosing]) {
		[menu open];
	} else if ([menu isOpenedOrOpening]) {
		if (item == menu.mainItem) {
			[menu close];
		} else {
			[menu closeWithSpecialAnimator:[[DLWMSelectionMenuAnimator alloc] init] forItem:item];
		}
	}
}

As you can see the delegate makes DLWidgetMenu use a custom animator for the tapped menu item by calling:

[menu closeWithSpecialAnimator:[[DLWMSelectionMenuAnimator alloc] init] forItem:item];

(The built-in DLWMSelectionMenuAnimator applies a scale-up in combination with a fade-out.)

Don't want that? Fine, just call [menu close]; then.

Okay, tapping is pretty standard stuff, right? Nothing too fancy. So how about moving a menu around using a pan gesture? Piece of cake:

- (void)receivedPan:(UIPanGestureRecognizer *)recognizer onItem:(DLWMMenuItem *)item inMenu:(DLWMMenu *)menu {
	// NSLog(@"%s", __FUNCTION__);
	if (item == menu.mainItem) {
		[menu moveTo:[recognizer locationInView:menu.superview] animated:NO];
	}
}

It's worth mentioning here that one should usually prefer [menu moveTo:… animated:…]; over menu.center = …; (while the menu is open, that is).

The reason for this is that DLWidgetMenu shrinks to just wrap its main item when closed and stretches to fit its superview when opened (in order to catch tap events outside its menu items). Just enable the debugging-mode (menu.debuggingEnabled = YES;) and you should get an idea of what this means.

Installation

Just copy the files in "DLWidgetMenu/Classes/..." into your project.

Alternatively you can install DLWidgetMenu into your project with CocoaPods.
Just add it to your Podfile: pod 'DLWidgetMenu'

Demos

DLWidgetMenu contains a demo app giving you a quick overview of all three included layouts.

ARC

DLWidgetMenu uses automatic reference counting (ARC).

Dependencies

None.

Creator

Vincent Esche (@regexident)

License

DLWidgetMenu is available under a modified BSD-3 clause license with the additional requirement of attribution. See the LICENSE file for more info.

dlwidgetmenu's People

Contributors

regexident avatar jmkk avatar rvi avatar schaechtele avatar

Watchers

James Cloos avatar BBC, LLC 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.