Skip to content

Commit 99053c2

Browse files
committed
Update README
1 parent 05b2f2c commit 99053c2

File tree

1 file changed

+153
-1
lines changed

1 file changed

+153
-1
lines changed

README.md

Lines changed: 153 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,154 @@
11
# ALButtonMenu
2-
A simple, fully customizable menu solution for iOS.
2+
3+
ALButtomMenu is a fast, customizable, fully documented menu solution for iOS.
4+
5+
### Preview
6+
7+
![Preview1](https://github.com/lobianco/ALButtonMenu/blob/master/Screenshots/demo1.gif?raw=true) ![Preview2](https://github.com/lobianco/ALButtonMenu/blob/master/Screenshots/demo2.gif?raw=true)
8+
9+
## Installation
10+
11+
Installation is easy.
12+
13+
### Cocoapods
14+
15+
1. `pod 'ALButtonMenu'` in your Podfile
16+
2. `#import <ALButtonMenu/ALButtonMenu.h>` in your view of choice
17+
18+
### Manually
19+
20+
1. [Download the .zip](https://github.com/lobianco/ALButtonMenu/archive/master.zip) from Github and copy `ALButtonMenu/Source` directory to your project
21+
2. `#import "ALButtonMenu.h"` in your view of choice
22+
23+
## Example Usage
24+
25+
Refer to the demo project for an interactive example, or just take a look at the code and comments below.
26+
27+
```objc
28+
29+
//
30+
// MyRootViewController.m
31+
//
32+
33+
// this, or whatever init method you choose to use
34+
- (instancetype)init
35+
{
36+
if ((self = [super init]) == NO)
37+
{
38+
return nil;
39+
}
40+
41+
// the layout that we'll use for the menu view controller
42+
ALMenuViewControllerLayout layout;
43+
44+
// the menu items will be displayed in a grid with this many columns. however, in landscape mode,
45+
// this value will be used for the number of rows instead.
46+
//
47+
layout.columns = 2;
48+
49+
// the spacing between menu items
50+
layout.itemSpacing = 15.f;
51+
52+
// the size of the menu items
53+
layout.itemSize = CGSizeMake(100.f, 100.f);
54+
55+
// can be an array of any number of items that inherit from ALButton or conform to the <ALMenuItem> protocol
56+
NSArray<UIView<ALMenuItem> *> *items = [self allMenuItems];
57+
58+
// create the view model for the menu view controller
59+
ALMenuViewControllerViewModel *menuViewModel = [[ALMenuViewControllerViewModel alloc] initWithItems:items layout:layout];
60+
61+
// tweak the default values. see ALMenuViewControllerViewModel.h for configurable properties
62+
menuViewModel.appearingAnimation = ALMenuViewControllerAppearingAnimationOrigin;
63+
64+
// the menu view controller can be an instance of ALMenuViewController, or any class that conforms
65+
// to the <ALMenuViewController> protocol
66+
//
67+
ALMenuViewController *menuViewController = [[ALMenuViewController alloc] initWithViewModel:menuViewModel];
68+
69+
// an instance of your view controller class
70+
MyViewController *viewController = [[MyViewController alloc] init];
71+
72+
// create the view model for the navigation coordinator
73+
ALNavigationCoordinatorViewModel *navViewModel = [[ALNavigationCoordinatorViewModel alloc] init];
74+
75+
// tweak the default values. see ALNavigationCoordinatorViewModel.h for configurable properties.
76+
navViewModel.buttonCanBeRepositioned = YES;
77+
78+
// create the navigation coordinator with the menu view controller and your app's root view controller. the
79+
// root view controller can be an instance of UIViewController or UINavigationController
80+
//
81+
_navigationCoordinator = [[ALNavigationCoordinator alloc] initWithViewModel:navViewModel menuViewController:menuViewController rootViewController:rootViewController];
82+
83+
// and be sure to assign yourself as the delegate. if you configure the navigation coordinator with a navigation
84+
// controller (instead of a root view controller), the coordinator will need to assign itself as that navigation
85+
// controller's delegate, so you can optionally receive those delegate callbacks via this assignment. just
86+
// implement the methods.
87+
//
88+
_navigationCoordinator.delegate = self;
89+
90+
return self;
91+
}
92+
93+
- (void)viewDidLoad
94+
{
95+
[super viewDidLoad];
96+
97+
// the navigation coordinator creates a navigation controller configured with the provided
98+
// menu view controller and root view controller. we need to add that navigation controller
99+
// to the view heirarchy
100+
//
101+
UIViewController *childViewController = self.navigationCoordinator.navigationController;
102+
103+
// then add it as a child view controller
104+
[self addChildViewController:childViewController];
105+
[self.view addSubview:childViewController.view];
106+
[childViewController didMoveToParentViewController:self];
107+
108+
// then notify the navigation coordinator about our viewDidLoad event
109+
[self.navigationCoordinator viewDidLoad];
110+
}
111+
112+
#pragma mark - ALNavigationCoordinatorDelegate
113+
114+
// be sure to implement the navigation coordinator's delegate method. it will fire when an item in the menu view controller is
115+
// tapped. return your specific UIViewController instance for that index.
116+
//
117+
- (UIViewController *)navigationCoordinator:(ALNavigationCoordinator *)navigationCoordinator viewControllerForMenuItemAtIndex:(NSUInteger)index
118+
{
119+
return [[MyViewController alloc] init];
120+
}
121+
122+
#pragma mark - Status bar
123+
124+
// optionally, return the menu view controller in this method to hide the status bar when the menu is shown.
125+
- (UIViewController *)childViewControllerForStatusBarHidden
126+
{
127+
return self.navigationCoordinator.menuViewController;
128+
}
129+
130+
#pragma mark - Rotation
131+
132+
// be sure to alert the navigation coordinator about size change events.
133+
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
134+
{
135+
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
136+
137+
[self.navigationCoordinator viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
138+
}
139+
140+
```
141+
142+
## Contact Me
143+
144+
You can reach me anytime at the addresses below. If you use ALButtonMenu, feel free to give me a shoutout on Twitter to let me know how you like it. I'd love to hear your thoughts!
145+
146+
Github: [lobianco](https://github.com/lobianco) <br>
147+
Twitter: [@lobnco](https://twitter.com/lobnco) <br>
148+
149+
150+
## Credits & License
151+
152+
ALButtonMenu is developed and maintained by Anthony Lobianco ([@lobnco](https://twitter.com/lobnco)). Licensed under the MIT License. Basically, I would appreciate attribution if you use it.
153+
154+
Enjoy!

0 commit comments

Comments
 (0)