1

嗨,我正在使用 JASidePanels 创建左侧菜单样式,但我想做一些特定的更改。

首先是我希望菜单只有 115 像素宽。为此,我发现:

self.leftFixedWidth = 115;

好的,但是,我仍然可以将中心面板向右滑动并查看“隐藏”的内容。有没有办法将其最大位置固定在 115 像素?就像脸书菜单一样?

4

1 回答 1

2

转到 JASidePanelController.m

find- (CGFloat)_correctMovement:(CGFloat)movement;方法,将其替换为:

- (CGFloat)_correctMovement:(CGFloat)movement {
    CGFloat position = _centerPanelRestingFrame.origin.x + movement;
    if (self.state == JASidePanelCenterVisible) {
        if (self.state != JASidePanelLeftVisible) {
          if (position >= self.leftVisibleWidth) {
            return self.leftVisibleWidth;
          }
        }
        else if ((position > 0.0f && !self.leftPanel) || (position < 0.0f && !self.rightPanel)) {
            return 0.0f;
        }
    } else if (self.state == JASidePanelRightVisible && !self.allowRightOverpan) {
        if ((position + _centerPanelRestingFrame.size.width) < (self.rightPanelContainer.frame.size.width - self.rightVisibleWidth)) {
            return 0.0f;
        } else if (position > self.rightPanelContainer.frame.origin.x) {
            return self.rightPanelContainer.frame.origin.x - _centerPanelRestingFrame.origin.x;
        }
    } else if (self.state == JASidePanelLeftVisible  && !self.allowLeftOverpan) {
        if (position > self.leftVisibleWidth) {
            return 0.0f;
        } else if (position < self.leftPanelContainer.frame.origin.x) {
            return  self.leftPanelContainer.frame.origin.x - _centerPanelRestingFrame.origin.x;
        }
    }
    return movement;
}
于 2013-05-15T12:41:10.210 回答