Browse Source

change the result constraint of maker.center.equalTo(CGPoint) to based on the original point of superview (#336)

* change center.equalTo

* fix logic
Living 9 years ago
parent
commit
da4426cb9a
1 changed files with 5 additions and 1 deletions
  1. 5 1
      Source/Constraint.swift

+ 5 - 1
Source/Constraint.swift

@@ -115,7 +115,11 @@ public class Constraint {
                         layoutToAttribute = layoutToAttributes[0]
                     }
                 } else {
-                    layoutToAttribute = layoutFromAttribute
+                    if self.to.target == nil && (layoutFromAttribute == .centerX || layoutFromAttribute == .centerY) {
+                        layoutToAttribute = layoutFromAttribute == .centerX ? .left : .top
+                    } else {
+                        layoutToAttribute = layoutFromAttribute
+                    }
                 }
             #else
                 if self.from.attributes == self.to.attributes {