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

add UI/NSLayoutGuide support like UIView #585

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

CancerQ
Copy link

@CancerQ CancerQ 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_equalToCGSizeMake6060));
    }];

    [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);
    }];

@CancerQ CancerQ 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