- Added bounce functionality (Let's say the right menu is for notifications, when you receive notification you bounce the right menu to let the user know that they should open the right menu to view the notification)
This commit is contained in:
parent
220512c37f
commit
439a6d76aa
|
|
@ -11,4 +11,6 @@
|
|||
|
||||
@interface HomeViewController : UIViewController <SlideNavigationControllerDelegate>
|
||||
|
||||
- (IBAction)bounceMenu:(id)sender;
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -27,4 +27,15 @@
|
|||
return YES;
|
||||
}
|
||||
|
||||
#pragma mark - IBActions -
|
||||
|
||||
- (IBAction)bounceMenu:(id)sender
|
||||
{
|
||||
static Menu menu = MenuLeft;
|
||||
|
||||
[[SlideNavigationController sharedInstance] bounceMenu:menu withCompletion:nil];
|
||||
|
||||
menu = (menu == MenuLeft) ? MenuRight : MenuLeft;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ typedef enum{
|
|||
|
||||
+ (SlideNavigationController *)sharedInstance;
|
||||
- (void)switchToViewController:(UIViewController *)viewController withCompletion:(void (^)())completion;
|
||||
- (void)bounceMenu:(Menu)menu withCompletion:(void (^)())completion;
|
||||
- (void)openMenu:(Menu)menu withCompletion:(void (^)())completion;
|
||||
- (void)closeMenuWithCompletion:(void (^)())completion;
|
||||
- (void)toggleLeftMenu;
|
||||
|
|
|
|||
|
|
@ -136,19 +136,41 @@ static SlideNavigationController *singletonInstance;
|
|||
self.view.layer.shadowOpacity = MENU_SHADOW_OPACITY;
|
||||
}
|
||||
|
||||
- (void)updateMenuFrameAndTransformAccordingToOrientation
|
||||
{
|
||||
// Animate rotatation when menu is open and device rotates
|
||||
CGAffineTransform transform = self.view.transform;
|
||||
self.leftMenu.view.transform = transform;
|
||||
self.rightMenu.view.transform = transform;
|
||||
|
||||
self.leftMenu.view.frame = [self initialRectForMenu];
|
||||
self.rightMenu.view.frame = [self initialRectForMenu];
|
||||
}
|
||||
|
||||
#pragma mark - Public Methods -
|
||||
|
||||
- (void)bounceMenu:(Menu)menu withCompletion:(void (^)())completion
|
||||
{
|
||||
[self prepareMenuForReveal:menu forcePrepare:YES];
|
||||
NSInteger movementDirection = (menu == MenuLeft) ? 1 : -1;
|
||||
|
||||
[UIView animateWithDuration:.16 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
|
||||
[self moveHorizontallyToLocation:30*movementDirection];
|
||||
} completion:^(BOOL finished){
|
||||
[UIView animateWithDuration:.1 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
|
||||
[self moveHorizontallyToLocation:0];
|
||||
} completion:^(BOOL finished){
|
||||
[UIView animateWithDuration:.12 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
|
||||
[self moveHorizontallyToLocation:16*movementDirection];
|
||||
} completion:^(BOOL finished){
|
||||
[UIView animateWithDuration:.08 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
|
||||
[self moveHorizontallyToLocation:0];
|
||||
} completion:^(BOOL finished){
|
||||
[UIView animateWithDuration:.08 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
|
||||
[self moveHorizontallyToLocation:6*movementDirection];
|
||||
} completion:^(BOOL finished){
|
||||
[UIView animateWithDuration:.06 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
|
||||
[self moveHorizontallyToLocation:0];
|
||||
} completion:^(BOOL finished){
|
||||
if (completion)
|
||||
completion();
|
||||
}];
|
||||
}];
|
||||
}];
|
||||
}];
|
||||
}];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)switchToViewController:(UIViewController *)viewController withCompletion:(void (^)())completion
|
||||
{
|
||||
if (self.avoidSwitchingToSameClassViewController && [self.topViewController isKindOfClass:viewController.class])
|
||||
|
|
@ -262,6 +284,17 @@ static SlideNavigationController *singletonInstance;
|
|||
|
||||
#pragma mark - Private Methods -
|
||||
|
||||
- (void)updateMenuFrameAndTransformAccordingToOrientation
|
||||
{
|
||||
// Animate rotatation when menu is open and device rotates
|
||||
CGAffineTransform transform = self.view.transform;
|
||||
self.leftMenu.view.transform = transform;
|
||||
self.rightMenu.view.transform = transform;
|
||||
|
||||
self.leftMenu.view.frame = [self initialRectForMenu];
|
||||
self.rightMenu.view.frame = [self initialRectForMenu];
|
||||
}
|
||||
|
||||
- (void)enableTapGestureToCloseMenu:(BOOL)enable
|
||||
{
|
||||
if (enable)
|
||||
|
|
|
|||
|
|
@ -94,9 +94,9 @@
|
|||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<subviews>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="0tp-7h-5YK">
|
||||
<rect key="frame" x="75" y="150" width="133" height="30"/>
|
||||
<rect key="frame" x="54" y="150" width="212" height="30"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<state key="normal" title="Push Another Page">
|
||||
<state key="normal" title="Push me somewhere else">
|
||||
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</state>
|
||||
<connections>
|
||||
|
|
@ -110,6 +110,16 @@
|
|||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="Pmu-aT-jf0">
|
||||
<rect key="frame" x="75" y="206" width="79" height="30"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<state key="normal" title="Bounce Me">
|
||||
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</state>
|
||||
<connections>
|
||||
<action selector="bounceMenu:" destination="mAB-md-uek" eventType="touchUpInside" id="ypv-y6-6jh"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
|
|
|
|||
Loading…
Reference in New Issue