Search code examples
iosios9mmdrawercontroller

iOS 9 multitasking with MMDrawer causes unwanted shadow


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?


Solution

  • 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];
    }