Git Product home page Git Product logo

rngridmenu's Introduction

RNGridMenu

A grid based menu view with field depth and bounce animation: inspired by Mailbox, and extended for multiple needs. I created this project out of a stint of boredom. This control is customizable to a degree, but kept simple so you can take it and spin your own subclass or fork out of it.

Installation

Installation with CocoaPods made available by thaberkern. Just add this line to your Podfile.

pod 'RNGridMenu', '~> 0.1.2'

Drag and drop the RNGridMenu .h and .m files into your project. To get this working, you'll need to include the following frameworks:

  • QuartCore
  • Accelerate

Usage

Getting started with RNGridMenu is dead simple. Just initialize it with a list of options, images, or both, and call the -show method. Like this:

NSArray *images = //...
NSArray *options = //...
RNGridMenu *av = [[RNGridMenu alloc] initWithOptions:options images:images delegate:self];
[av show];

There are 3 initialization methods in all for now. Note that the delgate is entirely optional. Just set that parameter to nil (though the control is kind of useless without it, right?).

// Note this changes the view to style RNGridMenuStyleList since there are no images
- (id)initWithOptions:(NSArray *)options delegate:(id <RNGridMenuDelegate>)delegate;

- (id)initWithImages:(NSArray *)images delegate:(id <RNGridMenuDelegate>)delegate;

// The count of both options and images must be equal (caught with assert)
- (id)initWithOptions:(NSArray *)options images:(NSArray *)images delegate:(id <RNGridMenuDelegate>)delegate;

Customization

@property (nonatomic, copy) UIColor *highlightColor;

The color that items will be highlighted with on selection. Defaults to table view selection blue.

@property (nonatomic, strong, readonly) UIColor *backgroundColor;

The background color of the main view (note this is a UIViewController subclass). Default is black with 0.7 alpha.

@property (nonatomic, assign) CGSize itemSize;

The size of a list or grid item. Default is 100x100.

@property (nonatomic, assign) CGFloat blurLevel;

The level of blur for the background image. Range is 0.0 to 1.0. Default is 0.3.

@property (nonatomic, assign) BOOL addsToWindow;

Set to YES if you want to add the control to the window of your app. Default is NO.

@property (nonatomic, assign) CGFloat animationDuration;

The time in seconds for the show and dismiss animation. Default is 0.25.

@property (nonatomic, copy) UIColor *itemTextColor;

The text color for list items. Default is white.

@property (nonatomic, copy) UIFont *itemFont;

The font used for list items. Default is bold size 14.

@property (nonatomic, assign) NSTextAlignment itemTextAlignment;

The text alignment of the item titles. Default center alignment.

@property (nonatomic, assign) RNGridMenuStyle menuStyle;

The list layout. Default RNGridMenuStyleGrid. Options are

RNGridMenuStyleDefault
RNGridMenuStyleList
@property (nonatomic, strong) UIView *headerView;

An optional header view. Make sure to set the frame height when setting. Same usage as UITableView header.

Credits

I finally got a solid implementation on responding to orientation changes by looking at the source of MBAlertView. Great project if you haven't seen it.

Sample icons provided by IcoMoon.

I followed Peter Steinberger's post on setting up UIAppearance.

The blurring algorithm was initially used from this post but then perfected by Club15CC in a pull request for RNBlurModalView.

Apps

If you've used this project in a live app, please let me know! Nothing makes me happier than seeing someone else take my work and go wild with it.

Todo

  • Images only
  • Vertical list with text only
  • Advanced styles - Item borders, gradients (Mailbox)
  • UIAppearance with styles
  • Title view
  • Readme
  • Cocoapods
  • More screenshots
  • Optional block callbacks

Contact

License

See LICENSE.

rngridmenu's People

Contributors

myell0w avatar rnystrom avatar xzenon 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  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

rngridmenu's Issues

Pod

Can you please create a pod for it?
P.S. If you don't know how to do it, I can do it for you.

Menu will scroll up together with table view

Hi great work on this project, I'm loving it.
However there is one little bug that probably hasn't seen very often.

I have a table view controller inside a tab bar view controller.
Currently, I make the call from the table view controller like this

- (IBAction)menuBarButtonPressed:(UIBarButtonItem *)sender
{
  // uncomment below to stop the table view from moving
  //  [self.tableView setContentOffset:self.tableView.contentOffset animated:NO];
  [HMTabBarViewController menuBarButtonPressedForViewController:self];
}

and then inside the tab bar view controller:

+ (void)menuBarButtonPressedForViewController:(UIViewController *)controller
{
  [(HMTabBarViewController *)[UIApplication sharedApplication].keyWindow.rootViewController menuBarButtonPressedForViewController:controller];
}

and

- (void)menuBarButtonPressedForViewController:(UIViewController *)controller
{
  RNGridMenu *gridMenu = [RNGridMenu visibleGridMenu];

  gridMenu = [[RNGridMenu alloc] initWithItems:self.gridMenuItems]; // Already have the menu items array
  [gridMenu setDelegate:self];

  [gridMenu showInViewController:controller center:CGPointMake(self.view.bounds.size.width/2.f, self.view.bounds.size.height/2.f)];
}

So this works great!

However, if I scroll the table view, and while the table view is moving, I try to open the grid menu, the grid menu will also move with the table view and it results in the grid menu either shifted up or down.

Next I tried to stop the table from moving before calling the grid menu, it works most of the time. However if the table view is in the process of refreshing(where you pull down the table and a spinner spins at the top). The grid menu will also be shifted.

grid menu bug

Memory retained without any leaks reported

Somewhere in the blur category there is a "leak". You can replicate this by running Instruments with Allocations on the demo. By toggling the menu over and over you'll see a gradual rise in memory use. If you use a retina iPad its an increase of almost 3mb per step! This is completely unacceptable.

I'm having a hard time figuring out where memory is being retained. The screenshot of the current view is taken on line 389 and line 452.

If anyone has any idea about what might be causing this, either respond here or offer a Pull Request to fix. I'd love any help!

Delegates and multiple grid menus

I don't know (yet) if this is a question or an issue. When I have multiple grid menus in the same view controller, when the delegate method is called, how can I identify the grid menu that was invoked. I know that there is a grid menu parameter in the delegate method, but none of its attributes will let me identify where the grid menu comes from (ie what button was pressed to make the grid menu appear). So what's the solution to that?

Wrong layout in Grid if item count is not divisble by 3

I have a grid with 8 and 10 menu items. Both render wrong on a iphone.

First of all on iPhone a max. of 3 Items per row is best. RNGridMenu chooses 4.

If I have 10 Menu items. The get layouted at the moment as:

x x x x
x     x
  x x 

which means 2 are missing

If I have 8 items they get layouted as 2 rows of 4 which can't display on iphone

UIAppearance

Add UIAppearance proxies for

  • Item borders
  • Highlight color
  • Background color
  • Item background color
  • Item font
  • Item font color

willDismissWithButtonIndex:option: not being called

- (void)gridMenu:(RNGridMenu *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex option:(NSString *)option
{
    NSLog(@"selected index %i with option %@",buttonIndex,option);
}

is not being called, the selected button is not being reported. Nothing is being logged.

Delegate gets released and delegate methods are not called

I was having problems with the delegate methods not getting called as the delegate was being released. Changing the delegate to a strong reference in the .h fixed it.

Ex.
// An optional delegate to receive information about what items were selected
@Property (nonatomic, strong) id delegate;

Tapping button doesn't dismiss menu

I had a table view controller inside a tab view controller. If I show the menu from the tab bar controller it will dismiss as expected. If I try to create and show the menu from the table view controller, the menu never dismisses but instead disappears very briefly and reappears. My workaround was the change the call to show if I was in the table view controller. The delegate is still set to self. Here is the before and after.

Before:
[av showInViewController:self center:CGPointMake(self.view.bounds.size.width/2.f, self.view.bounds.size.height/2.f)];

After:
[av showInViewController:self.parentViewController center:CGPointMake(self.view.bounds.size.width/2.f, self.view.bounds.size.height/2.f)];

Hope this helps anyone else that had the same thing happen.

Blur change color of uiimageview, become white

Hello, in my project i have some UIImageView with a glare effect, it's just a image that create a shadow on a picture, and when i show the RNGridMenu, become white, this:
schermata 2013-09-26 alle 14 06 22

that white image before display the menu was transparent...

how i can fix it?

iOS 7 Animation

I'm not going to go into details because of the NDA (and if this breaks the NDA let me know immediately), but dismissing the view on iOS 7 does not invoke the scale animation. This might be a bug to report, or it might not.

If you find the solution please do not post the details here. I'd prefer either an email or a pull request so we can avoid any NDA issues.

BUG or Issue

Hello, First of all I would like to thank you for your nice and interesting tool.
I have one recomentation for you.
I use your tool in an app I am developing and in IOS7 it produses one or two warnings!
Can you please correct this small issue.

Thank you in advance

George N. Gerardis

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.