mirror of https://github.com/SnapKit/SnapKit
Allow automagic constraining
This commit is contained in:
parent
9949aba7e8
commit
4abf189fc9
|
@ -323,9 +323,6 @@ class Constraint {
|
||||||
// get layout from
|
// get layout from
|
||||||
let layoutFrom: View? = self.fromItem.view
|
let layoutFrom: View? = self.fromItem.view
|
||||||
|
|
||||||
// get layout to
|
|
||||||
let layoutTo: View? = self.toItem.view
|
|
||||||
|
|
||||||
// get layout relation
|
// get layout relation
|
||||||
let layoutRelation: NSLayoutRelation = (self.relation != nil) ? self.relation!.layoutRelation : .Equal
|
let layoutRelation: NSLayoutRelation = (self.relation != nil) ? self.relation!.layoutRelation : .Equal
|
||||||
|
|
||||||
|
@ -337,6 +334,12 @@ class Constraint {
|
||||||
var layoutConstant: CGFloat = layoutToAttribute.snp_constantForValue(self.constant)
|
var layoutConstant: CGFloat = layoutToAttribute.snp_constantForValue(self.constant)
|
||||||
layoutConstant += layoutToAttribute.snp_offsetForValue(self.offset)
|
layoutConstant += layoutToAttribute.snp_offsetForValue(self.offset)
|
||||||
|
|
||||||
|
// get layout to
|
||||||
|
var layoutTo: View? = self.toItem.view
|
||||||
|
if layoutTo == nil && layoutToAttribute != .Width && layoutToAttribute != .Height {
|
||||||
|
layoutTo = installOnView
|
||||||
|
}
|
||||||
|
|
||||||
// create layout constraint
|
// create layout constraint
|
||||||
let layoutConstraint = LayoutConstraint(
|
let layoutConstraint = LayoutConstraint(
|
||||||
item: layoutFrom,
|
item: layoutFrom,
|
||||||
|
|
|
@ -37,7 +37,7 @@ class ViewController: UIViewController {
|
||||||
|
|
||||||
|
|
||||||
view1.snp_makeConstraints { make in
|
view1.snp_makeConstraints { make in
|
||||||
make.top.and.left.equalTo(superview).insets(padding)
|
make.top.and.left.equalTo(CGPointZero).insets(padding)
|
||||||
make.size.equalTo(CGSizeMake(100, 50))
|
make.size.equalTo(CGSizeMake(100, 50))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue