Skip to content

Commit 0241695

Browse files
committed
Update README.md
1 parent 7fa9e10 commit 0241695

File tree

1 file changed

+78
-21
lines changed

1 file changed

+78
-21
lines changed

README.md

Lines changed: 78 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
iOS-Slide-Menu
2-
==============
2+
---------
33

44
iOS Slide Menu built on top of UINavigationController.
55

@@ -9,9 +9,16 @@ Features:
99
- Configurable Buttons
1010
- Allows Enable/Disable menu by implmenting delegate methods
1111
- Tap/Swipe gesture recognizer to Open/Close the Menus
12+
- Allows custom animation
1213

1314
![alt tag](https://raw.github.com/aryaxt/iOS-Slide-Menu/master/slideMenuAnimation.gif)
1415

16+
Version 1.3.0 Notes
17+
---------
18+
If you are updating from previous versions you'll get compile errors, due to changes to RevealAnimations.
19+
Animation configuration is now handled differently, and is separated from the SlideNavigationController.
20+
Please see bwlow for more information.
21+
1522
Setup
1623
---------
1724
```
@@ -36,6 +43,7 @@ SomeViewController *vc = [[SomeViewController alloc] init];
3643
```
3744
Configuring Left and Right menu for different Viewcontrollers
3845
---------
46+
You decide whether to enable or disable slide functionality on each viewController by implementing the following delegate methods of SlideNavigationControllerDelegate. These methods are optional, and if not implemented the menu functionality will be disabled for that particulat viewController.
3947
```
4048
@interface MyViewController : UIViewController <SlideNavigationControllerDelegate>
4149
@end
@@ -56,34 +64,83 @@ Configuring Left and Right menu for different Viewcontrollers
5664
@end
5765
```
5866

59-
Configuring menu offset
67+
Public properties
6068
---------
61-
Menu offset can be configured for both portrait and landscape mode
69+
###### avoidSwitchingToSameClassViewController
70+
Default value is set to YES.
71+
If set to YES when switching to a new ViewController if the new viewcontroller is the same type as the current viewcontroller it'll close the menu instead of switching to the viewController.
72+
73+
If set to NO it'll switch to the viewController regardless of types
74+
75+
This can be usefull when you have a menu item, and when the user selects an already selected menu item you don't want to navigate to a new instance of the viewController
76+
###### enableSwipeGesture
77+
When set to YES user can swipe to open the menu
78+
79+
When set to NO swipe is disabled, and use can only open the menu using the UIBarButtonItem added to the navigationBar
80+
###### rightMenu
81+
The viewController of the right menu in the navigationController
82+
###### leftMenu
83+
The viewController of the left menu in the navigationController
84+
###### leftBarButtonItem
85+
Default value is null. When this button is set navigationController uses this UIBarButtonItem as the leftItem. this property is intended to be used when a custom UIBarButton is needed (UIBarButtonItem initialized with a custom view)
86+
###### rightBarButtonItem
87+
Behaves exactly the same as leftbarButtonItem, but it's used as the right button for the menu
88+
###### portraitSlideOffset
89+
Default value of portraitSlideOffset is 60. This means when the menu is open, the width of the visible portion of the navigation controller is 60 pixels in portrait mode
90+
###### landscapeSlideOffset
91+
Default value of portraitSlideOffset is 60. This means when the menu is open, the width of the visible portion of the navigation controller is 60 pixels in landscape mode
92+
###### menuRevealAnimator
93+
menuRevealAnimator is used to animate the left/right menu during reveal. The default value is nil that means no animations occure when opening/closing the menu.
94+
95+
There are existing animation that can be used out of the box. These animation classes can be configured through init method options.
96+
97+
- SlideNavigationContorllerAnimatorSlide
98+
- SlideNavigationContorllerAnimatorFade
99+
- SlideNavigationContorllerAnimatorScale
100+
- SlideNavigationContorllerAnimatorScaleAndFade
101+
- SlideNavigationContorllerAnimatorSlideAndFade
102+
62103
```
63-
[SlideNavigationController sharedInstance].landscapeSlideOffset = 400;
64-
[SlideNavigationController sharedInstance].portraitSlideOffset = 60;
104+
SlideNavigationContorllerAnimatorSlideAndFade *alideAndFadeAnimator = [[SlideNavigationContorllerAnimatorSlideAndFade alloc] initWithMaximumFadeAlpha:.8 fadeColor:[UIColor redColor] andSlideMovement:100];
105+
[SlideNavigationController sharedInstance].menuRevealAnimator = alideAndFadeAnimator;
65106
```
66-
Menu Reveal Animations
107+
Custom Animations
67108
---------
68-
There are three types of animations that can be applied when revealing the menu
109+
SlideNavigationController allows custom reveal animations. In order to add custom animations create a new class implementing SlideNavigationContorllerAnimator protocol. For more information take a look at the existing animation classes.
69110

70-
```
71-
MenuRevealAnimationNone
72-
MenuRevealAnimationFade
73-
MenuRevealAnimationSlide
74-
MenuRevealAnimationSlideAndFade
111+
###### - (void)prepareMenuForAnimation:(Menu)menu;
112+
This method gets called right before the menu is about to reveal
113+
###### - (void)animateMenu:(Menu)menu withProgress:(CGFloat)progress;
114+
This method gets called as the menu reveal occurs, and passes the progress to be used for animations(progress is between 0 and 1)
115+
###### - (void)clear;
116+
This method gets called if for any resons the instance of animator is being changed. For instance, the animator is changed from SlideNavigationContorllerAnimatorFade to SlideNavigationContorllerAnimatorSlide. In this method you should cleanup the state of the menu if neede. For instance if you added a view to the menu for reveal animation, you should remove it when clear gets called.
117+
Public Methods
118+
---------
119+
###### + (SlideNavigationController *)sharedInstance;
120+
Returns the singleton instance of SlideNavigationController
75121

76-
[SlideNavigationController sharedInstance].menuRevealAnimation = MenuRevealAnimationSlideAndFade;
77-
```
122+
###### - (void)switchToViewController:(UIViewController *)viewController withCompletion:(void (^)())completion;
123+
Pops to root ViewController, then pushes the new ViewController and finally calls the completion
78124

79-
The opacity applied during a fade animation can be configured using a property on SlideNavigationController called menuRevealAnimationFadeMaximumAlpha. This value can be anywhere between 0 and 1, and it represents the darkes a menu can become. The color of fade layer can also be configured using the property called menuRevealAnimationFadeColor
80-
```
81-
[SlideNavigationController sharedInstance].menuRevealAnimationFadeColor = [UIColor greenColor];
82-
[SlideNavigationController sharedInstance].menuRevealAnimationFadeMaximumAlpha = .5;
83-
```
125+
###### - (void)openMenu:(Menu)menu withCompletion:(void (^)())completion;
126+
Opens a given menu and calls the completion block oppon animation completion
127+
128+
###### - (void)closeMenuWithCompletion:(void (^)())completion;
129+
Closes the menu and calls the completion block oppon animation completion
84130

85-
The movement of menu during a slide animation can also be configured
131+
###### - (void)toggleLeftMenu;
132+
Toggles the left menu open or close depending on the existing state. This was made public in order to pass the selector to a custom UIBarButtonItem (ex: UIBarButtonItem with a button as a custom view)
86133
```
87-
[SlideNavigationController sharedInstance].menuRevealAnimationSlideMovement = 50;
134+
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
135+
[button setImage:[UIImage imageNamed:@"menu-button"] forState:UIControlStateNormal];
136+
[button addTarget:[SlideNavigationController sharedInstance] action:@selector(toggleRightMenu) forControlEvents:UIControlEventTouchUpInside];
137+
UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
138+
[SlideNavigationController sharedInstance].rightBarButtonItem = rightBarButtonItem;
88139
```
89140

141+
###### - (void)toggleRightMenu;
142+
Works exactly the same as toggleLeftMenu, but used to toggle left menu
143+
144+
###### - (BOOL)isMenuOpen;
145+
Returns a boolean stating whether the menu is open or not
146+

0 commit comments

Comments
 (0)