我正在使用
ECSlidingViewController
来实现“汉堡包”菜单。我使用SDK 7.0,但将部署目标更改为iOS 6.1后,我现在正在尝试在旧于7的iOS上测试我的应用程序。问题出在setEdgesForExtendedLayout
上。有一个旧版本的 ECSlidingViewController
适用于旧的系统版本。所以我的问题是如何在iOS 6.1及更早版本中切换到旧版本,而在iOS 7.0及更高版本中使用新版本。我从两个 ECSlidingViewController
项目中都包含文件(不是通过cocoapods,但如果需要更改也不是问题)。我猜我需要检查操作系统版本,然后更改导入,但我不确定这是否足够,并且对于两个项目的最佳命名约定是什么。我猜它们应该在不同的文件夹中(如ECSlidingViewController和ECSlidingViewControllerOld),但类名称应该相同,对吗?
编辑:带有edgesForExtendedLayout
代码示例:- (CGRect)underLeftViewCalculatedFrameForTopViewPosition:(ECSlidingViewControllerTopViewPosition)position {
CGRect frameFromDelegate = [self frameFromDelegateForViewController:self.underLeftViewController
topViewPosition:position];
if (!CGRectIsInfinite(frameFromDelegate)) return frameFromDelegate;
CGRect containerViewFrame = self.view.bounds;
if (!(self.underLeftViewController.edgesForExtendedLayout & UIRectEdgeTop)) {
CGFloat topLayoutGuideLength = [self.topLayoutGuide length];
containerViewFrame.origin.y = topLayoutGuideLength;
containerViewFrame.size.height -= topLayoutGuideLength;
}
if (!(self.underLeftViewController.edgesForExtendedLayout & UIRectEdgeBottom)) {
CGFloat bottomLayoutGuideLength = [self.bottomLayoutGuide length];
containerViewFrame.size.height -= bottomLayoutGuideLength;
}
if (!(self.underLeftViewController.edgesForExtendedLayout & UIRectEdgeRight)) {
containerViewFrame.size.width = self.anchorRightRevealAmount;
}
return containerViewFrame;
}