Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions REMenu/REMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,10 @@ typedef NS_ENUM(NSInteger, REMenuLiveBackgroundStyle) {

- (id)initWithItems:(NSArray *)items;
- (void)showFromRect:(CGRect)rect inView:(UIView *)view;
- (void)showFromRect:(CGRect)rect inView:(UIView *)view offsetX:(CGFloat)offsetX width:(CGFloat)width;
- (void)showInView:(UIView *)view;
- (void)showFromNavigationController:(UINavigationController *)navigationController;
- (void)showFromNavigationController:(UINavigationController *)navigationController offsetX:(CGFloat)offsetX width:(CGFloat)width;
- (void)setNeedsLayout;
- (void)closeWithCompletion:(void (^)(void))completion;
- (void)close;
Expand Down
35 changes: 28 additions & 7 deletions REMenu/REMenu.m
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ - (id)initWithItems:(NSArray *)items
}

- (void)showFromRect:(CGRect)rect inView:(UIView *)view
{
[self showFromRect:rect inView:view offsetX:0 width:rect.size.width];
}

- (void)showFromRect:(CGRect)rect inView:(UIView *)view offsetX:(CGFloat)offsetX width:(CGFloat)width
{
if (self.isAnimating) {
return;
Expand Down Expand Up @@ -220,7 +225,18 @@ - (void)showFromRect:(CGRect)rect inView:(UIView *)view

// Set up frames
//
self.menuWrapperView.frame = CGRectMake(0, -self.combinedHeight - navigationBarOffset, rect.size.width, self.combinedHeight + navigationBarOffset);
self.menuWrapperView.frame = CGRectMake(offsetX, -self.combinedHeight - navigationBarOffset, width, self.combinedHeight + navigationBarOffset);
if(width != rect.size.width)
{
if(self.menuWrapperView.center.x < rect.size.width/2)
{
self.menuWrapperView.autoresizingMask = UIViewAutoresizingFlexibleRightMargin;
}
else
{
self.menuWrapperView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
}
}
self.menuView.frame = self.menuWrapperView.bounds;
if (REUIKitIsFlatMode() && self.liveBlur) {
self.toolbar.frame = self.menuWrapperView.bounds;
Expand Down Expand Up @@ -250,7 +266,7 @@ - (void)showFromRect:(CGRect)rect inView:(UIView *)view
options:UIViewAnimationOptionBeginFromCurrentState|UIViewAnimationOptionCurveEaseInOut
animations:^{
self.backgroundView.alpha = self.backgroundAlpha;
CGRect frame = self.menuView.frame;
CGRect frame = self.menuWrapperView.frame;
frame.origin.y = -40.0 - self.separatorHeight;
self.menuWrapperView.frame = frame;
} completion:^(BOOL finished) {
Expand All @@ -262,7 +278,7 @@ - (void)showFromRect:(CGRect)rect inView:(UIView *)view
options:UIViewAnimationOptionBeginFromCurrentState|UIViewAnimationOptionCurveEaseInOut
animations:^{
self.backgroundView.alpha = self.backgroundAlpha;
CGRect frame = self.menuView.frame;
CGRect frame = self.menuWrapperView.frame;
frame.origin.y = -40.0 - self.separatorHeight;
self.menuWrapperView.frame = frame;
} completion:^(BOOL finished) {
Expand All @@ -276,7 +292,7 @@ - (void)showFromRect:(CGRect)rect inView:(UIView *)view
options:UIViewAnimationOptionBeginFromCurrentState|UIViewAnimationOptionCurveEaseInOut
animations:^{
self.backgroundView.alpha = self.backgroundAlpha;
CGRect frame = self.menuView.frame;
CGRect frame = self.menuWrapperView.frame;
frame.origin.y = -40.0 - self.separatorHeight;
self.menuWrapperView.frame = frame;
} completion:^(BOOL finished) {
Expand All @@ -291,13 +307,18 @@ - (void)showInView:(UIView *)view
}

- (void)showFromNavigationController:(UINavigationController *)navigationController
{
[self showFromNavigationController:navigationController offsetX:0 width:navigationController.navigationBar.frame.size.width];
}

- (void)showFromNavigationController:(UINavigationController *)navigationController offsetX:(CGFloat)offsetX width:(CGFloat)width
{
if (self.isAnimating) {
return;
}

self.navigationBar = navigationController.navigationBar;
[self showFromRect:CGRectMake(0, 0, navigationController.navigationBar.frame.size.width, navigationController.view.frame.size.height) inView:navigationController.view];
[self showFromRect:CGRectMake(0, 0, navigationController.navigationBar.frame.size.width, navigationController.view.frame.size.height) inView:navigationController.view offsetX:offsetX width:width];
self.containerView.appearsBehindNavigationBar = self.appearsBehindNavigationBar;
self.containerView.navigationBar = navigationController.navigationBar;
if (self.appearsBehindNavigationBar) {
Expand All @@ -318,7 +339,7 @@ - (void)closeWithCompletion:(void (^)(void))completion
delay:0.0
options:UIViewAnimationOptionBeginFromCurrentState|UIViewAnimationOptionCurveEaseInOut
animations:^ {
CGRect frame = self.menuView.frame;
CGRect frame = self.menuWrapperView.frame;
frame.origin.y = - self.combinedHeight - navigationBarOffset;
self.menuWrapperView.frame = frame;
self.backgroundView.alpha = 0;
Expand Down Expand Up @@ -349,7 +370,7 @@ - (void)closeWithCompletion:(void (^)(void))completion

if (self.bounce) {
[UIView animateWithDuration:self.bounceAnimationDuration animations:^{
CGRect frame = self.menuView.frame;
CGRect frame = self.menuWrapperView.frame;
frame.origin.y = -20.0;
self.menuWrapperView.frame = frame;
} completion:^(BOOL finished) {
Expand Down