iOS 9 使用 MMDrawer 进行多任务处理会导致不需要的阴影
iOS 9 multitasking with MMDrawer causes unwanted shadow
我在使用 MMDrawer 时发现,在更改多任务处理的大小时,我的侧边栏视图完全被遮蔽或完全不被遮蔽。
有什么办法可以解决这个问题吗?
我搜索并找到了一个可行的解决方案 here。
所以我在 MMDrawerController.m 文件中添加了以下代码:
- (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];
}
我在使用 MMDrawer 时发现,在更改多任务处理的大小时,我的侧边栏视图完全被遮蔽或完全不被遮蔽。
有什么办法可以解决这个问题吗?
我搜索并找到了一个可行的解决方案 here。
所以我在 MMDrawerController.m 文件中添加了以下代码:
- (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];
}