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

Idea: make.superview #79

Closed
grav opened this issue Jun 29, 2014 · 2 comments
Closed

Idea: make.superview #79

grav opened this issue Jun 29, 2014 · 2 comments

Comments

@grav
Copy link

grav commented Jun 29, 2014

I often use a pattern as the following:

- (instancetype)init...
UIView * mySubView = [UIView new];
[myView addSubview:mySubView];
[mySubView mas_makeConstraints:^(MASConstraintMaker *make) {
    make.edges.equalTo(mySubView.superview);
}];

So I refer to myView indirectly using mySubView.superview. This is because it often eases refactoring, for instance if I want to introduce a container view between myView and mySubView.

I wonder if it would make sense to introduce a make.superview? This way, the constraints related to the actual view would be easier to recognize.

Also, I try to use mas_makeConstraints: as often as I can, since in my mind, constraints are almost always immutable, except when animating.

What are your comments to the above points? Are they patterns or anti-patterns? :-)

@cloudkite
Copy link
Contributor

@grav this has been suggested before see #61.

However if you enable autoboxing in v0.5 you can know write this as

make.edges.equalTo(UIEdgeInsetsZero);

Sorry haven't had the time to update the docs recently. But take a look at the changelog

@cloudkite
Copy link
Contributor

@grav closing for now, but happy to reopen if this doesn't address your use case

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

2 participants