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

Fixes bug in MASExampleUpdateView #489

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fixes bug in MASExampleUpdateView #489

wants to merge 1 commit into from

Conversation

ShannonChenCHN
Copy link

@ShannonChenCHN ShannonChenCHN commented Nov 8, 2017

This is a bug found in iOS Example Project.
When I tapped the growingButton in MASExampleUpdateView, the button didn't grow. Probably we need to change the width constraint priority of growingButton from low to medium. I have tried this fix on my project, and it worked fine.

When I printed all constraints of growingButton, and I got this:

[self.growingButton updateConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self);
        make.width.equalTo(@(self.buttonSize.width)).priorityLow();
        make.height.equalTo(@(self.buttonSize.height)).priorityLow();
        make.width.lessThanOrEqualTo(self);
        make.height.lessThanOrEqualTo(self);
    }];
    
    for (NSLayoutConstraint *constraint in self.growingButton.constraints) {
        NSLog(@"---- priority : %@, %@\n\n", constraint, @(constraint.priority));
    }
    
    /**
     priority : <MASLayoutConstraint:0x6000000b8ae0 UIButton:0x7f81ea51a290.width == 130 ^low>, 250
     
     priority : <MASLayoutConstraint:0x6000000b8b40 UIButton:0x7f81ea51a290.height == 130 ^low>, 250
     
     priority : <NSContentSizeLayoutConstraint:0x6040000b4fa0 UIButton:0x7f81ea51a290.width == 66>, 1000
     
     priority : <NSContentSizeLayoutConstraint:0x6040000b5000 UIButton:0x7f81ea51a290.height == 30>, 1000
     */

So, It looks like make.width.lessThanOrEqualTo(self); makes a constraint with a default priority( NSLayoutPriorityRequired).

When tapped the `growingButton`, it didn't grow. Probably we need to change the width constraint priority of `growingButton` from low to medium. I have tried this fix on my project, and it worked fine.
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