0

I was working with MMDrawer and I saw that my sidebar view got fully shadowed or not shadowed at all when changing size of multitasking.

Is there any way to accomplish this problem?

Mehdi Hosseinzadeh
  • 1,160
  • 11
  • 25

1 Answers1

0

I've searched and found a working solution here.

So I've added below code to my MMDrawerController.m file:

- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
    [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
    // willRotateToInterfaceOrientation code goes here
    BOOL gestureInProgress = NO;

    for (UIGestureRecognizer *gesture in self.view.gestureRecognizers) {
        if (gesture.state == UIGestureRecognizerStateChanged) {
            [gesture setEnabled:NO];
            [gesture setEnabled:YES];
            gestureInProgress = YES;
        }

        if (gestureInProgress) {
            [self resetDrawerVisualStateForDrawerSide:self.openSide];
        }
    }

    [coordinator animateAlongsideTransition:^(id < UIViewControllerTransitionCoordinatorContext > context) {
                 // willAnimateRotationToInterfaceOrientation code goes here
                 [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];

                 if (self.showsShadow) {
                     CGPathRef oldShadowPath = self.centerContainerView.layer.shadowPath;

                 if (oldShadowPath) {
                     CFRetain(oldShadowPath);
                 }

                 [self updateShadowForCenterView];

                 if (oldShadowPath) {
                     [self.centerContainerView.layer addAnimation:((^{
                         CABasicAnimation *transition = [CABasicAnimation animationWithKeyPath:@"shadowPath"];
                         transition.fromValue = (__bridge id)oldShadowPath;
                         transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
                         return transition;
                 })())
                       forKey:@"transition"];
                         CFRelease(oldShadowPath);
                     }
                 }
             }
             completion:nil];
}
Mehdi Hosseinzadeh
  • 1,160
  • 11
  • 25