Skip to content

Conversation

@Yize9
Copy link

@Yize9 Yize9 commented Aug 27, 2020

add layoutGuide support equalToSuperview & greaterThanOrEqualToSuperview & lessThanOrEqualToSuperview

    MAS_VIEW * contentView = MAS_VIEW.new;
    contentView.backgroundColor = self.randomColor;
    contentView.layer.borderColor = self.randomColor.CGColor;
    contentView.layer.borderWidth = 2 ;
    [self addSubview:contentView];

    MAS_VIEW * leftView = MAS_VIEW.new;
    leftView.backgroundColor = self.randomColor;
    leftView.layer.borderColor = self.randomColor.CGColor;
    leftView.layer.borderWidth = 2 ;
    [contentView addSubview:leftView];

    MAS_VIEW * rightView = MAS_VIEW.new;
    rightView.backgroundColor = self.randomColor;
    rightView.layer.borderColor = self.randomColor.CGColor;
    rightView.layer.borderWidth = 2 ;
    [contentView addSubview:rightView];

    [contentView mas_makeConstraints:^(MASConstraintMaker * make){
        make.left.right.top.equalToSuperview();
        make.height.mas_equalTo(self.mas_height).multipliedBy0.3);
    }];

    MAS_LAYOUT_GUIDE *layout= [MAS_LAYOUT_GUIDE mas_allocWithOwningView:contentView];
    [layout mas_makeConstraints:^(MASConstraintMaker * _Nonnull make){
        make.center.equalToSuperview();
        make.size.mas_equalTo(CGSizeMake(6060));
    }];

    [leftView makeConstraints:^(MASConstraintMaker * make){
        make.top.mas_equalTo(layout);
        make.right.mas_equalTo(layout.mas_left);
        make.bottom.mas_equalTo(layout);
        make.width.mas_equalTo(layout.mas_width);
    }];

    [rightView makeConstraints:^(MASConstraintMaker * make){
        make.top.mas_equalTo(layout);
        make.left.mas_equalTo(layout.mas_right);
        make.bottom.mas_equalTo(layout);
        make.width.mas_equalTo(layout.mas_width);
    }];

@Yize9 Yize9 changed the title add layoutGuide support add UI/NSLayoutGuide support like UIView Aug 27, 2020
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

Successfully merging this pull request may close these issues.

1 participant