浏览代码

Allow size attributes to be installed on a view itself

Robert Payne 11 年之前
父节点
当前提交
c75495cf4c
共有 1 个文件被更改,包括 6 次插入0 次删除
  1. 6 0
      Snap/Constraint.swift

+ 6 - 0
Snap/Constraint.swift

@@ -297,8 +297,14 @@ public class Constraint {
         } else {
             installOnView = self.fromItem.view?.superview
             if installOnView == nil {
+              if self.fromItem.attributes == ConstraintAttributes.Width || self.fromItem.attributes == ConstraintAttributes.Height {
+                installOnView = self.fromItem.view
+              }
+              
+              if installedOnView == nil {
                 NSException(name: "Cannot Install Constraint", reason: "Missing superview", userInfo: nil).raise()
                 return []
+              }
             }
         }