Skip to content
Open
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
23 changes: 23 additions & 0 deletions RESideMenu/RESideMenu.m
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ - (void)showLeftMenuViewController
[UIView animateWithDuration:self.animationDuration animations:^{
if (self.scaleContentView) {
self.contentViewContainer.transform = CGAffineTransformMakeScale(self.contentViewScaleValue, self.contentViewScaleValue);
[self updateContentViewAdditionalSafeAreaInsets];
} else {
self.contentViewContainer.transform = CGAffineTransformIdentity;
}
Expand Down Expand Up @@ -333,6 +334,7 @@ - (void)showRightMenuViewController
[UIView animateWithDuration:self.animationDuration animations:^{
if (self.scaleContentView) {
self.contentViewContainer.transform = CGAffineTransformMakeScale(self.contentViewScaleValue, self.contentViewScaleValue);
[self updateContentViewAdditionalSafeAreaInsets];
} else {
self.contentViewContainer.transform = CGAffineTransformIdentity;
}
Expand Down Expand Up @@ -388,6 +390,7 @@ - (void)hideMenuViewControllerAnimated:(BOOL)animated
}
strongSelf.contentViewContainer.transform = CGAffineTransformIdentity;
strongSelf.contentViewContainer.frame = strongSelf.view.bounds;
[self updateContentViewAdditionalSafeAreaInsets];
if (strongSelf.scaleMenuView) {
strongSelf.menuViewContainer.transform = strongSelf.menuViewControllerTransformation;
}
Expand Down Expand Up @@ -474,6 +477,21 @@ - (void)resetContentViewScale
self.contentViewContainer.frame = frame;
}

- (void)updateContentViewAdditionalSafeAreaInsets
{
if (@available(iOS 11.0, *)) {
UIEdgeInsets insets = self.contentViewController.additionalSafeAreaInsets;
insets.top = CGRectGetMinY(self.contentViewContainer.frame);
CGFloat topSafeArea = CGRectGetMinY(self.view.safeAreaLayoutGuide.layoutFrame);
if (insets.top > topSafeArea) {
insets.top = topSafeArea;
} else if (insets.top < 0.0) {
insets.top = 0.0;
}
self.contentViewController.additionalSafeAreaInsets = insets;
}
}

#pragma mark -
#pragma mark iOS 7 Motion Effects (Private)

Expand Down Expand Up @@ -649,9 +667,11 @@ - (void)panGestureRecognized:(UIPanGestureRecognizer *)recognizer
CGFloat oppositeScale = (1 - (contentViewScale - 1));
self.contentViewContainer.transform = CGAffineTransformMakeScale(oppositeScale, oppositeScale);
self.contentViewContainer.transform = CGAffineTransformTranslate(self.contentViewContainer.transform, point.x, 0);
[self updateContentViewAdditionalSafeAreaInsets];
} else {
self.contentViewContainer.transform = CGAffineTransformMakeScale(contentViewScale, contentViewScale);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have found that scaling layer.transform instead of view.transform does not cause this bug

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job! Thanks

self.contentViewContainer.transform = CGAffineTransformTranslate(self.contentViewContainer.transform, point.x, 0);
[self updateContentViewAdditionalSafeAreaInsets];
}

self.leftMenuViewController.view.hidden = self.contentViewContainer.frame.origin.x < 0;
Expand All @@ -660,11 +680,13 @@ - (void)panGestureRecognized:(UIPanGestureRecognizer *)recognizer
if (!self.leftMenuViewController && self.contentViewContainer.frame.origin.x > 0) {
self.contentViewContainer.transform = CGAffineTransformIdentity;
self.contentViewContainer.frame = self.view.bounds;
[self updateContentViewAdditionalSafeAreaInsets];
self.visible = NO;
self.leftMenuVisible = NO;
} else if (!self.rightMenuViewController && self.contentViewContainer.frame.origin.x < 0) {
self.contentViewContainer.transform = CGAffineTransformIdentity;
self.contentViewContainer.frame = self.view.bounds;
[self updateContentViewAdditionalSafeAreaInsets];
self.visible = NO;
self.rightMenuVisible = NO;
}
Expand Down Expand Up @@ -791,6 +813,7 @@ - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInte

if (self.scaleContentView) {
self.contentViewContainer.transform = CGAffineTransformMakeScale(self.contentViewScaleValue, self.contentViewScaleValue);
[self updateContentViewAdditionalSafeAreaInsets];
} else {
self.contentViewContainer.transform = CGAffineTransformIdentity;
}
Expand Down