Giter Site home page Giter Site logo

Comments (3)

dyygs avatar dyygs commented on July 27, 2024

我也刚好碰到了这个问题,说下我的解决思路,是通过拦截以下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);
    }];
}

from zhpopupcontroller.

whyAreYouSoShy avatar whyAreYouSoShy commented on July 27, 2024

我也刚好碰到了这个问题,说下我的解决思路,是通过拦截以下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确实贴着底部的,这种怎么解决

from zhpopupcontroller.

Mr-yuwei avatar Mr-yuwei commented on July 27, 2024
  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;
    }
}

from zhpopupcontroller.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.