Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iPhone x底部弹出没有去掉安全区域 #36

Open
LYluyu opened this issue Apr 24, 2018 · 3 comments
Open

iPhone x底部弹出没有去掉安全区域 #36

LYluyu opened this issue Apr 24, 2018 · 3 comments

Comments

@LYluyu
Copy link

LYluyu commented Apr 24, 2018

iPhone x底部弹出没有去掉安全区域

@dyygs
Copy link

dyygs commented Dec 26, 2018

我也刚好碰到了这个问题,说下我的解决思路,是通过拦截以下2个代理方法实现的,具体原因在注释里边都写了:

- (void)popupControllerDidPresent:(zhPopupController *)popupController {
    // 在view即将出现的时候,主动修改布局来满足底部约束
    [self.xxtActionSheet mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.xxtActionSheet.superview);
        make.height.mas_equalTo(74*[self.homeworkDemandList count]);
        make.bottom.equalTo(self.mas_bottomLayoutGuide);
    }];
}

- (void)popupControllerWillDismiss:(zhPopupController *)popupController {
    // 由于手动修改约束,会导致关闭动画过高,所以把height尽量缩小
    [self.xxtActionSheet mas_updateConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.xxtActionSheet.superview);
        make.height.mas_equalTo(1);
        make.bottom.equalTo(self.xxtActionSheet.superview);
    }];
}

@whyAreYouSoShy
Copy link

我也刚好碰到了这个问题,说下我的解决思路,是通过拦截以下2个代理方法实现的,具体原因在注释里边都写了:

- (void)popupControllerDidPresent:(zhPopupController *)popupController {
    // 在view即将出现的时候,主动修改布局来满足底部约束
    [self.xxtActionSheet mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.xxtActionSheet.superview);
        make.height.mas_equalTo(74*[self.homeworkDemandList count]);
        make.bottom.equalTo(self.mas_bottomLayoutGuide);
    }];
}

- (void)popupControllerWillDismiss:(zhPopupController *)popupController {
    // 由于手动修改约束,会导致关闭动画过高,所以把height尽量缩小
    [self.xxtActionSheet mas_updateConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.xxtActionSheet.superview);
        make.height.mas_equalTo(1);
        make.bottom.equalTo(self.xxtActionSheet.superview);
    }];
}

我是让他弹出一个带有footer的tableview,然后底部的安全区域是透明的,footer没有贴紧底部,cell确实贴着底部的,这种怎么解决

@Mr-yuwei
Copy link

Mr-yuwei commented Jan 21, 2019

  1. 直接导入源码,以获取X系列safeAreaInsets.bottom的值,修改zhPopupLayoutTypeBottom的位置。
  2. 导入源码 ,声明一个类似contentInset属性,同样需要判断是否是 zhPopupLayoutTypeBottom
CGFloat safeAreaBottomInset  = 0.0f; 
  if (@available(iOS 11.0, *)) {
      safeAreaBottomInset = [UIApplication sharedApplication].keyWindow.safeAreaInsets.bottom;
  }
return CGPointMake(point.x, _maskView.bounds.size.height - _popupView.bounds.size.height / 2 -safeAreaBottomInset );

3 . 不需要修改任何源码,新建一个zhPopupController类别,重写finishedCenter方法

如下:

- (CGPoint)finishedCenter {
    UIView     *_maskView = [self valueForKey:@"_maskView"];
    UIView     *_popupView = [self valueForKey:@"_popupView"];
    NSInteger  _layoutType = [[self valueForKey:@"_layoutType"] integerValue];
    NSInteger  _slideStyle = [[self valueForKey:@"_slideStyle"] integerValue];
    CGPoint point = _maskView.center;
    switch (_layoutType) {
        case zhPopupLayoutTypeTop:
            return CGPointMake(point.x,
                               _popupView.bounds.size.height / 2);
        case zhPopupLayoutTypeBottom:  // 
            return CGPointMake(point.x,
                               _maskView.bounds.size.height - _popupView.bounds.size.height / 2 - 安全域);
        case zhPopupLayoutTypeLeft:
            return CGPointMake(_popupView.bounds.size.width / 2,
                               point.y);
        case zhPopupLayoutTypeRight:
            return CGPointMake(_maskView.bounds.size.width - _popupView.bounds.size.width / 2,
                               point.y);
        default: // zhPopupLayoutTypeCenter
        {
            if (_slideStyle == zhPopupSlideStyleShrinkInOut1 ||
                _slideStyle == zhPopupSlideStyleShrinkInOut2) {
                _popupView.transform = CGAffineTransformIdentity;
            } else if (_slideStyle == zhPopupSlideStyleFade) {
                _maskView.alpha = 1;
            }
        }
            return point;
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants