Snapkit: 3.0.1 - Some types does not conform to ConstraintOffsetTarget

Created on 20 Sep 2016  路  4Comments  路  Source: SnapKit/SnapKit

New Issue Checklist

  • [x] I have looked at the Documentation
  • [x] I have read the F.A.Q.
  • [x] I have filled out this issue template.

    Issue Info

| Info | Value |
| --- | --- |
| Platform | e.g. ios/osx/tvos |
| Platform Version | 8.0 |
| SnapKit Version | 3.0.1 |
| Integration Method | CocoaPods |

Issue Description

I used to have some code that did

titleLabel.snp.makeConstraints() { make in
    make.top.left.right.equalTo(self).offset(UIEdgeInsets(top: self.padding, left: self.padding, bottom: 0, right: -self.padding))
}

But now I am getting an error because offset takes ConstraintOffsetTarget, which UIEdgeInsets and CGPoint no longer conform to.

It looks like the NSLayoutAttribute.snp_constantForValue function got migrated into ConstraintConstantTarget.constraintConstantTargetValueFor(layoutAttribute:), so I'm guessing it might not be too hard to add in?

I haven't looked too hard into the implementation, so if I'm missing something, let me know! I just noticed that this was no longer building after upgrading 馃槄

All 4 comments

@cjwirth you're probably going to want to use equalTo(self).inset(UIEdgeInsets) and you no longer need to invert the right or bottom values as SnapKit does this by default.

you're probably going to want to use equalTo(self).inset(UIEdgeInsets)

aah, if this is all it was, then it's definitely my fault, sorry about that!
What's the difference between inset and offset in the context of SnapKit?

And what about CGPoint? That's still not conforming to either constraint insetor offset target protocols.

you no longer need to invert the right or bottom values as SnapKit does this by default.

Aah, so I don't have to do right: -self.padding, I can just do right: self.padding these days? Cool!

@cjwirth CGPoint was removed because it's ambiguous for things like make.top.bottom.equalTo(CGPoint) you have to use constants and separate them out now if they are supposed to be different values.

Oh I guess that makes sense. It appears to be working 馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mkoppanen picture mkoppanen  路  3Comments

phongle6893 picture phongle6893  路  4Comments

seljabali picture seljabali  路  3Comments

aeves313 picture aeves313  路  4Comments

romk1n picture romk1n  路  3Comments