diff --git a/Keynote Layout presentation.key b/Keynote Layout presentation.key index 8d9492a9..0efc5fdf 100644 Binary files a/Keynote Layout presentation.key and b/Keynote Layout presentation.key differ diff --git a/MCSwiftLayout/Extensions/UIView+PinLayout.swift b/MCSwiftLayout/Extensions/UIView+PinLayout.swift index 27889298..76d36bf3 100644 --- a/MCSwiftLayout/Extensions/UIView+PinLayout.swift +++ b/MCSwiftLayout/Extensions/UIView+PinLayout.swift @@ -17,6 +17,10 @@ public extension UIView { return PinList(view: self) } +// public var pin: Layout { +// return Layout(view: self) +// } + public var edge: EdgeList { return EdgeList(view: self) } @@ -26,26 +30,26 @@ public extension UIView { // } } -// Could be part of another GitHub repo -//public extension UIView { - /*public var top: CGFloat { +// Could be part of another GitHub repo? +public extension UIView { + public var top: CGFloat { get { return frame.origin.y } - set { frame = CGRect(x: left, y: roundFloatToDisplayScale(newValue), width: width, height: height) } + set { frame = CGRect(x: left, y: Coordinates.roundFloatToDisplayScale(newValue), width: width, height: height) } } public var left: CGFloat { get { return frame.origin.x } - set { frame = CGRect(x: roundFloatToDisplayScale(newValue), y: top, width: width, height: height) } + set { frame = CGRect(x: Coordinates.roundFloatToDisplayScale(newValue), y: top, width: width, height: height) } } public var bottom: CGFloat { get { return frame.maxY } - set { height = roundFloatToDisplayScale(newValue - top) } + set { height = Coordinates.roundFloatToDisplayScale(newValue - top) } } public var right: CGFloat { get { return frame.maxX } - set { width = roundFloatToDisplayScale(newValue - left) } + set { width = Coordinates.roundFloatToDisplayScale(newValue - left) } } public var hCenter: CGFloat { @@ -56,7 +60,7 @@ public extension UIView { public var vCenter: CGFloat { get { return top + (height / 2) } set { top = newValue - (height / 2) } - }*/ + } /* public var topLeft: CGPoint { get { return CGPoint(x: left, y: top) } @@ -130,18 +134,22 @@ public extension UIView { } } */ -// public var size: CGSize { -// get { return CGSize(width: width, height: height) } -// set { frame = CGRect(x: left, y: top, width: ceilFloatToDisplayScale(newValue.width), height: ceilFloatToDisplayScale(newValue.height)) } -// } -// -// public var width: CGFloat { -// get { return frame.size.width } -// set { frame = CGRect(x: left, y: top, width: ceilFloatToDisplayScale(newValue), height: height) } -// } -// -// public var height: CGFloat { -// get { return frame.size.height } -// set { frame = CGRect(x: left, y: top, width: width, height: ceilFloatToDisplayScale(newValue)) } -// } -//} + public var size: CGSize { + get { return CGSize(width: frame.size.width, height: frame.size.height) } + set { frame = CGRect(x: frame.origin.x, y: frame.origin.y, + width: Coordinates.ceilFloatToDisplayScale(newValue.width), + height: Coordinates.ceilFloatToDisplayScale(newValue.height)) } + } + + public var width: CGFloat { + get { return frame.size.width } + set { frame = CGRect(x: frame.origin.x, y: frame.origin.y, + width: Coordinates.ceilFloatToDisplayScale(newValue), height: height) } + } + + public var height: CGFloat { + get { return frame.size.height } + set { frame = CGRect(x: frame.origin.x, y: frame.origin.y, + width: width, height: Coordinates.ceilFloatToDisplayScale(newValue)) } + } +} diff --git a/MCSwiftLayout/Layout.swift b/MCSwiftLayout/Layout.swift index 9e9bcf6a..9281320b 100644 --- a/MCSwiftLayout/Layout.swift +++ b/MCSwiftLayout/Layout.swift @@ -7,6 +7,12 @@ // import UIKit + +//constrain(button1, button2) { button1, button2 in +// button1.right == button2.left - 12 +//} + + /* =============================================== QUESTIONS: @@ -71,12 +77,23 @@ import UIKit =============================================== TODO: =============================================== + - Verifier ce qui se passe avec UIView lorsque width/height sont négatif. Est-ce que ça devient 0? Appliquer la même + règle et enlever le guard du code dans setWidth et setHeight. + + - frame(of: UIView) + - frame() + + - right(percent: CGFloat), left(percent: CGFloat), ... + - In CSS + - negative width and height is not applied, alson for percentages + - right/bottom: negative value and percentage is applyed + right: -20px increase the width by an extra 20 pixels + right: -50% increase the width by an extra 50% (width = parent's width * 1.50) + + - Faire sample avec un scrollview qui contient une viewA et: 1- pin une view ne faisant pas parti de la scrollview à viewA 2- pin une view à un coin de viewA et un autre coin de cette view à un coin qui ne bouge pas. - - Faire un sample avec A pinner à droite avec une largeur de 30. Et pinner viewB.left à gauche de la superview - et viewB.right à la viewA. Comme ça lorsque la taille de l'écran change uniquement viewB va changer de taille. - - sizeToFit() devrait prendre un parametre indiquant si on doit caster les nouvelles valeur de width et de height (forceSize, castSize, ...?) @@ -86,20 +103,10 @@ import UIKit - Support hCenter + left or right - Support vCenter + top or bottom - - implement sizeThatFits - - Insets should be applied to width and height before calling view.sizeThatFits() - - Est-ce que aView.layout.pinTopLeft(superview.pin.center) fonctionne? - peut-être enlever tous les UIView.topLeft, UIView.topCenter, ....? - - Implement this: ?? - - view.layout.left(backgroundView.edge.left) - - view.layout.top(backgroundView.edge.bottom) - - - Implement Layout + Layout operator - - - width(percentage: CGFloat, of view: UIView) - maxWidth(), minWidth(), maxHeight(), minHeight() - inset(t:? = nil l:? = nil b:? = nil r:? = nil ) ?? @@ -119,12 +126,29 @@ import UIKit .strokeWidth(1), .baselineOffset(5.2) ]) + + - Inspired by https://github.com/robb/Cartography + // Other possible syntax + layout(viewA) { viewA in { + viewA.pinTopLeft(to: viewB.pin.topLeft).margin(20) + viewA.width(20).height(20) + } */ fileprivate typealias Context = () -> String fileprivate typealias Size = (width: CGFloat?, height: CGFloat?) + +public func pin(_ view: UIView) -> Layout { + return Layout(view: view) +} + public class Layout { - static var logConflicts = true + #if DEBUG + public static var logConflicts = true + #else + public static var logConflicts = false + #endif + // static var useBottomRightCssStyle = false fileprivate let view: UIView @@ -235,7 +259,7 @@ public class Layout { // @discardableResult public func pinTopLeft(to point: CGPoint) -> Layout { - return setTopLeft(point, context: { return "topLeft(CGPoint(x: \(point.x), y: \(point.y)))" }) + return setTopLeft(point, context: { return "pinTopLeft(to: CGPoint(x: \(point.x), y: \(point.y)))" }) } /// Position the topLeft on the specified view's pin. @@ -248,20 +272,10 @@ public class Layout { return self } - /// Position on the topLeft corner of the specified view. -// @discardableResult -// public func pinTopLeft(to relativeView: UIView) -> Layout { -// func context() -> String { return "topLeft(of: \(view))" } -// if let coordinates = computeCoordinates(forPin: .topLeft, of: relativeView, context: context) { -// setTopLeft(coordinates, context: context) -// } -// return self -// } - /// Position on the topLeft corner of its parent. @discardableResult public func pinTopLeft() -> Layout { - func context() -> String { return "topLeft()" } + func context() -> String { return "pinTopLeft()" } if let layoutSuperview = validateLayoutSuperview(context: context) { if let coordinates = computeCoordinates(forPin: .topLeft, of: layoutSuperview, context: context) { setTopLeft(coordinates, context: context) @@ -272,7 +286,7 @@ public class Layout { @discardableResult public func pinTopCenter(to point: CGPoint) -> Layout { - return setTopCenter(point, context: { return "topCenter(CGPoint(x: \(point.x), y: \(point.y)))" }) + return setTopCenter(point, context: { return "pinTopCenter(to: CGPoint(x: \(point.x), y: \(point.y)))" }) } /// Position the topCenter on the specified view's pin. @@ -284,21 +298,11 @@ public class Layout { } return self } - - /// Position on the topCenter corner of the specified view. -// @discardableResult -// public func pinTopCenter(to relativeView: UIView) -> Layout { -// func context() -> String { return "topCenter(of: \(view))" } -// if let coordinates = computeCoordinates(forPin: .topCenter, of: relativeView, context: context) { -// setTopCenter(coordinates, context: context) -// } -// return self -// } /// Position on the topCenter corner of its parent. @discardableResult public func pinTopCenter() -> Layout { - func context() -> String { return "topCenter()" } + func context() -> String { return "pinTopCenter()" } if let layoutSuperview = validateLayoutSuperview(context: context) { if let coordinates = computeCoordinates(forPin: .topCenter, of: layoutSuperview, context: context) { setTopCenter(coordinates, context: context) @@ -309,7 +313,7 @@ public class Layout { @discardableResult public func pinTopRight(to point: CGPoint) -> Layout { - return setTopRight(point, context: { return "topRight(CGPoint(x: \(point.x), y: \(point.y)))" }) + return setTopRight(point, context: { return "pinTopRight(to: CGPoint(x: \(point.x), y: \(point.y)))" }) } /// Position the topRight on the specified view's pin. @@ -321,21 +325,11 @@ public class Layout { } return self } - - /// Position on the topRight corner of the specified view. -// @discardableResult -// public func pinTopRight(to relativeView: UIView) -> Layout { -// func context() -> String { return "topRight(of: \(view))" } -// if let coordinates = computeCoordinates(forPin: .topRight, of: relativeView, context: context) { -// setTopRight(coordinates, context: context) -// } -// return self -// } /// Position on the topRight corner of its parent. @discardableResult public func pinTopRight() -> Layout { - func context() -> String { return "topRight()" } + func context() -> String { return "pinTopRight()" } if let layoutSuperview = validateLayoutSuperview(context: context) { if let coordinates = computeCoordinates(forPin: .topRight, of: layoutSuperview, context: context) { setTopRight(coordinates, context: context) @@ -346,7 +340,7 @@ public class Layout { @discardableResult public func pinLeftCenter(to point: CGPoint) -> Layout { - return setLeftCenter(point, context: { return "leftCenter(CGPoint(x: \(point.x), y: \(point.y)))" }) + return setLeftCenter(point, context: { return "pinLeftCenter(to: CGPoint(x: \(point.x), y: \(point.y)))" }) } /// Position the leftCenter on the specified view's pin. @@ -359,20 +353,10 @@ public class Layout { return self } - /// Position on the leftCenter corner of the specified view. -// @discardableResult -// public func pinLeftCenter(to relativeView: UIView) -> Layout { -// func context() -> String { return "leftCenter(of: \(view))" } -// if let coordinates = computeCoordinates(forPin: .leftCenter, of: relativeView, context: context) { -// setLeftCenter(coordinates, context: context) -// } -// return self -// } - /// Position on the leftCenter corner of its parent. @discardableResult public func pinLeftCenter() -> Layout { - func context() -> String { return "leftCenter()" } + func context() -> String { return "pinLeftCenter()" } if let layoutSuperview = validateLayoutSuperview(context: context) { if let coordinates = computeCoordinates(forPin: .leftCenter, of: layoutSuperview, context: context) { setLeftCenter(coordinates, context: context) @@ -383,7 +367,7 @@ public class Layout { @discardableResult public func pinCenter(to point: CGPoint) -> Layout { - return setCenter(point, context: { return "centers(CGPoint(x: \(point.x), y: \(point.y)))" }) + return setCenter(point, context: { return "pinCenter(to: CGPoint(x: \(point.x), y: \(point.y)))" }) } /// Position the centers on the specified view's pin. @@ -396,18 +380,9 @@ public class Layout { return self } -// @discardableResult -// public func pinCenter(to relativeView: UIView) -> Layout { -// func context() -> String { return "centers(of: \(view))" } -// if let coordinates = computeCoordinates(forPin: PinType.center, of: relativeView, context: context) { -// setCenter(coordinates, context: context) -// } -// return self -// } - @discardableResult public func pinCenter() -> Layout { - func context() -> String { return "center()" } + func context() -> String { return "pinCenter()" } if let layoutSuperview = validateLayoutSuperview(context: context) { if let coordinates = computeCoordinates(forPin: .center, of: layoutSuperview, context: context) { setCenter(coordinates, context: context) @@ -418,7 +393,7 @@ public class Layout { @discardableResult public func pinRightCenter(to point: CGPoint) -> Layout { - return setRightCenter(point, context: { return "rightCenter(CGPoint(x: \(point.x), y: \(point.y)))" }) + return setRightCenter(point, context: { return "pinRightCenter(to: CGPoint(x: \(point.x), y: \(point.y)))" }) } /// Position the rightCenter on the specified view's pin. @@ -431,20 +406,10 @@ public class Layout { return self } - /// Position on the rightCenter corner of the specified view. -// @discardableResult -// public func pinRightCenter(to relativeView: UIView) -> Layout { -// func context() -> String { return "rightCenter(of: \(view))" } -// if let coordinates = computeCoordinates(forPin: .rightCenter, of: relativeView, context: context) { -// setRightCenter(coordinates, context: context) -// } -// return self -// } - /// Position on the rightCenter corner of its parent. @discardableResult public func pinRightCenter() -> Layout { - func context() -> String { return "rightCenter()" } + func context() -> String { return "pinRightCenter()" } if let layoutSuperview = validateLayoutSuperview(context: context) { if let coordinates = computeCoordinates(forPin: .rightCenter, of: layoutSuperview, context: context) { setRightCenter(coordinates, context: context) @@ -455,7 +420,7 @@ public class Layout { @discardableResult public func pinBottomLeft(to point: CGPoint) -> Layout { - return setBottomLeft(point, context: { return "bottomLeft(CGPoint(x: \(point.x), y: \(point.y)))" }) + return setBottomLeft(point, context: { return "pinBottomLeft(to: CGPoint(x: \(point.x), y: \(point.y)))" }) } /// Position the bottomLeft on the specified view's pin. @@ -467,21 +432,11 @@ public class Layout { } return self } - - /// Position on the bottomLeft corner of the specified view. -// @discardableResult -// public func pinBottomLeft(to relativeView: UIView) -> Layout { -// func context() -> String { return "bottomLeft(of: \(view))" } -// if let coordinates = computeCoordinates(forPin: .bottomLeft, of: relativeView, context: context) { -// setBottomLeft(coordinates, context: context) -// } -// return self -// } /// Position on the bottomLeft corner of its parent. @discardableResult public func pinBottomLeft() -> Layout { - func context() -> String { return "bottomLeft()" } + func context() -> String { return "pinBottomLeft()" } if let layoutSuperview = validateLayoutSuperview(context: context) { if let coordinates = computeCoordinates(forPin: .bottomLeft, of: layoutSuperview, context: context) { setBottomLeft(coordinates, context: context) @@ -492,7 +447,7 @@ public class Layout { @discardableResult public func pinBottomCenter(to point: CGPoint) -> Layout { - return setBottomCenter(point, context: { return "bottomCenter(CGPoint(x: \(point.x), y: \(point.y)))" }) + return setBottomCenter(point, context: { return "pinBottomCenter(to: CGPoint(x: \(point.x), y: \(point.y)))" }) } /// Position the bottomCenter on the specified view's pin. @@ -504,21 +459,11 @@ public class Layout { } return self } - - /// Position on the bottomCenter corner of the specified view. -// @discardableResult -// public func pinBottomCenter(to relativeView: UIView) -> Layout { -// func context() -> String { return "bottomCenter(of: \(view))" } -// if let coordinates = computeCoordinates(forPin: .bottomCenter, of: relativeView, context: context) { -// setBottomCenter(coordinates, context: context) -// } -// return self -// } - + /// Position on the bottomCenter corner of its parent. @discardableResult public func pinBottomCenter() -> Layout { - func context() -> String { return "bottomCenter()" } + func context() -> String { return "pinBottomCenter()" } if let layoutSuperview = validateLayoutSuperview(context: context) { if let coordinates = computeCoordinates(forPin: .bottomCenter, of: layoutSuperview, context: context) { setBottomCenter(coordinates, context: context) @@ -529,7 +474,7 @@ public class Layout { @discardableResult public func pinBottomRight(to point: CGPoint) -> Layout { - return setBottomRight(point, context: { return "bottomRight(CGPoint(x: \(point.x), y: \(point.y)))" }) + return setBottomRight(point, context: { return "pinBottomRight(to: CGPoint(x: \(point.x), y: \(point.y)))" }) } /// Position the bottomRight on the specified view's pin. @@ -541,21 +486,11 @@ public class Layout { } return self } - - /// Position on the bottomRight corner of the specified view. -// @discardableResult -// public func pinBottomRight(to relativeView: UIView) -> Layout { -// func context() -> String { return "bottomRight(of: \(view))" } -// if let coordinates = computeCoordinates(forPin: .bottomRight, of: relativeView, context: context) { -// setBottomRight(coordinates, context: context) -// } -// return self -// } /// Position on the bottomRight corner of its parent. @discardableResult public func pinBottomRight() -> Layout { - func context() -> String { return "bottomRight()" } + func context() -> String { return "pinBottomRight()" } if let layoutSuperview = validateLayoutSuperview(context: context) { if let coordinates = computeCoordinates(forPin: .bottomRight, of: layoutSuperview, context: context) { setBottomRight(coordinates, context: context) @@ -709,16 +644,30 @@ public class Layout { return setWidth(width, context: { return "width(\(width))" }) } + @discardableResult + public func width(percent: CGFloat) -> Layout { + func context() -> String { return "width(percent: \(percent)%)" } + guard let layoutSuperview = validateLayoutSuperview(context: context) else { return self } + return setWidth(layoutSuperview.frame.width * percent / 100, context: context) + } + @discardableResult public func width(of view: UIView) -> Layout { return setWidth(view.frame.size.width, context: { return "width(of: \(view))" }) } - + @discardableResult public func height(_ height: CGFloat) -> Layout { return setHeight(height, context: { return "height(\(height))" }) } + @discardableResult + public func height(percent: CGFloat) -> Layout { + func context() -> String { return "height(percent: \(percent)%)" } + guard let layoutSuperview = validateLayoutSuperview(context: context) else { return self } + return setHeight(layoutSuperview.frame.height * percent / 100, context: context) + } + @discardableResult public func height(of view: UIView) -> Layout { return setHeight(view.frame.size.height, context: { return "height(of: \(view))" }) @@ -864,7 +813,7 @@ extension Layout { warnConflict(context, ["bottom": bottom!, "height": height!]) } else if vCenter != nil { warnConflict(context, ["Vertical Center": vCenter!]) - } else if top != nil { + } else if top != nil && top! != value { warnPropertyAlreadySet("top", propertyValue: top!, context: context) } else { top = value @@ -876,7 +825,7 @@ extension Layout { warnConflict(context, ["right": right!, "width": width!]) } else if hCenter != nil { warnConflict(context, ["Horizontal Center": hCenter!]) - } else if left != nil { + } else if left != nil && left! != value { warnPropertyAlreadySet("left", propertyValue: left!, context: context) } else { left = value @@ -888,7 +837,7 @@ extension Layout { warnConflict(context, ["left": left!, "width": width!]) } else if hCenter != nil { warnConflict(context, ["Horizontal Center": hCenter!]) - } else if right != nil { + } else if right != nil && right! != value { warnPropertyAlreadySet("right", propertyValue: right!, context: context) } else { right = value @@ -900,7 +849,7 @@ extension Layout { warnConflict(context, ["top": top!, "height": height!]) } else if vCenter != nil { warnConflict(context, ["Vertical Center": vCenter!]) - } else if bottom != nil { + } else if bottom != nil && bottom! != value { warnPropertyAlreadySet("bottom", propertyValue: bottom!, context: context) } else { bottom = value @@ -912,8 +861,8 @@ extension Layout { warnConflict(context, ["left": left!]) } else if right != nil { warnConflict(context, ["right": right!]) - } else if hCenter != nil { - warnPropertyAlreadySet("hCenter", propertyValue: hCenter!, context: context) + } else if hCenter != nil && hCenter! != value { + warnPropertyAlreadySet("Horizontal Center", propertyValue: hCenter!, context: context) } else { hCenter = value } @@ -924,8 +873,8 @@ extension Layout { warnConflict(context, ["top": top!]) } else if bottom != nil { warnConflict(context, ["bottom": bottom!]) - } else if vCenter != nil { - warnPropertyAlreadySet("vCenter", propertyValue: vCenter!, context: context) + } else if vCenter != nil && vCenter! != value { + warnPropertyAlreadySet("Vertical Center", propertyValue: vCenter!, context: context) } else { vCenter = value } @@ -1058,7 +1007,7 @@ extension Layout { fileprivate func computeCoordinates(forEdge edge: EdgeType, of relativeView: UIView, context: Context) -> CGPoint? { guard let layoutSuperview = validateLayoutSuperview(context: context) else { return nil } - guard let relativeSuperview = relativeView.superview else { warn("relative view's superview is nil", context: context); return nil } + guard let relativeSuperview = relativeView.superview else { warn("The view must be added to a UIView before being used as a reference.", context: context); return nil } return computeCoordinates(edge.point(for: relativeView), layoutSuperview, relativeView, relativeSuperview) } @@ -1067,7 +1016,7 @@ extension Layout { if let parentView = view.superview { return parentView } else { - warn("Layout's view must be added to a UIView before being layouted using this method.", context: context) + warn("The view must be added to a UIView before being layouted using this method.", context: context) return nil } } @@ -1224,21 +1173,21 @@ extension Layout { fileprivate func warn(_ text: String, context: Context) { guard Layout.logConflicts else { return } - print("\n👉 \(text) (\(context()))\n") + print("\n👉 Layout Warning: \(context()). \(text)\n") } fileprivate func warnPropertyAlreadySet(_ propertyName: String, propertyValue: CGFloat, context: Context) { guard Layout.logConflicts else { return } - print("\n👉 The \(propertyName) property has already been set to \(propertyValue). (\(context()))\n") + print("\n👉 Layout Conflict: \(context()) won't be applied since it value has already been set to \(propertyValue).\n") } fileprivate func warnPropertyAlreadySet(_ propertyName: String, propertyValue: CGSize, context: Context) { - print("\n👉 The \(propertyName) property has already been set to CGSize(width: \(propertyValue.width), height: \(propertyValue.height)). (\(context()))\n") + print("\n👉 Layout Conflict: \(context()) won't be applied since it value has already been set to CGSize(width: \(propertyValue.width), height: \(propertyValue.height)).\n") } fileprivate func warnConflict(_ context: Context, _ properties: [String: CGFloat]) { guard Layout.logConflicts else { return } - var warning = "\n👉 Layout Conflict: '\(context())' won't be applied since it conflicts with the following already set properties:\n" + var warning = "\n👉 Layout Conflict: \(context()) won't be applied since it conflicts with the following already set properties:\n" properties.forEach { (key, value) in warning += " \(key): \(value)\n" } diff --git a/MCSwiftLayoutSample/MCSwiftLayoutSample.xcodeproj/project.pbxproj b/MCSwiftLayoutSample/MCSwiftLayoutSample.xcodeproj/project.pbxproj index 5625c74e..e1e61b11 100644 --- a/MCSwiftLayoutSample/MCSwiftLayoutSample.xcodeproj/project.pbxproj +++ b/MCSwiftLayoutSample/MCSwiftLayoutSample.xcodeproj/project.pbxproj @@ -7,8 +7,8 @@ objects = { /* Begin PBXBuildFile section */ - 2439CC281E6658C3003326FB /* ReferenceProxy in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 2439CC241E665858003326FB /* MCSwiftLayout.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 2439CC2B1E6658CC003326FB /* ReferenceProxy in Frameworks */ = {isa = PBXBuildFile; fileRef = 2439CC241E665858003326FB /* MCSwiftLayout.framework */; }; + 2439CC281E6658C3003326FB /* MCSwiftLayout.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 2439CC241E665858003326FB /* MCSwiftLayout.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 2439CC2B1E6658CC003326FB /* MCSwiftLayout.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2439CC241E665858003326FB /* MCSwiftLayout.framework */; }; 2439CC351E665BF6003326FB /* MenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2439CC331E665BF6003326FB /* MenuView.swift */; }; 2439CC361E665BF6003326FB /* MenuViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2439CC341E665BF6003326FB /* MenuViewController.swift */; }; 2439CC4B1E665C6B003326FB /* BasicView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2439CC381E665C6B003326FB /* BasicView.swift */; }; @@ -35,6 +35,8 @@ 24E6547B1E68F27D00A72A8B /* BothEdgesSnappedViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24E654791E68F27D00A72A8B /* BothEdgesSnappedViewController.swift */; }; 24E654821E69041B00A72A8B /* Expect.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24E654811E69041B00A72A8B /* Expect.swift */; }; DE6C3D736B571B80E207DF6A /* Pods_MCSwiftLayoutSample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AAD69688AA2A3F0994F3074E /* Pods_MCSwiftLayoutSample.framework */; }; + DF66F9DA1E8493E000ADB8D5 /* PinScrollingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF66F9D81E8493E000ADB8D5 /* PinScrollingView.swift */; }; + DF66F9DB1E8493E000ADB8D5 /* PinScrollingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF66F9D91E8493E000ADB8D5 /* PinScrollingViewController.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -68,7 +70,7 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( - 2439CC281E6658C3003326FB /* ReferenceProxy in Embed Frameworks */, + 2439CC281E6658C3003326FB /* MCSwiftLayout.framework in Embed Frameworks */, ); name = "Embed Frameworks"; runOnlyForDeploymentPostprocessing = 0; @@ -105,6 +107,8 @@ 24E654791E68F27D00A72A8B /* BothEdgesSnappedViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BothEdgesSnappedViewController.swift; sourceTree = ""; }; 24E654811E69041B00A72A8B /* Expect.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Expect.swift; sourceTree = ""; }; AAD69688AA2A3F0994F3074E /* Pods_MCSwiftLayoutSample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_MCSwiftLayoutSample.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + DF66F9D81E8493E000ADB8D5 /* PinScrollingView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = PinScrollingView.swift; path = PinScrolling/PinScrollingView.swift; sourceTree = ""; }; + DF66F9D91E8493E000ADB8D5 /* PinScrollingViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = PinScrollingViewController.swift; path = PinScrolling/PinScrollingViewController.swift; sourceTree = ""; }; F121E291CADD796B007C04BB /* Pods-MCSwiftLayoutSample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MCSwiftLayoutSample.release.xcconfig"; path = "Pods/Target Support Files/Pods-MCSwiftLayoutSample/Pods-MCSwiftLayoutSample.release.xcconfig"; sourceTree = ""; }; F1ACB0EACBD84B57B50D472D /* Pods-MCSwiftLayoutSample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MCSwiftLayoutSample.debug.xcconfig"; path = "Pods/Target Support Files/Pods-MCSwiftLayoutSample/Pods-MCSwiftLayoutSample.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -114,7 +118,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 2439CC2B1E6658CC003326FB /* ReferenceProxy in Frameworks */, + 2439CC2B1E6658CC003326FB /* MCSwiftLayout.framework in Frameworks */, DE6C3D736B571B80E207DF6A /* Pods_MCSwiftLayoutSample.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -152,6 +156,7 @@ 2439CC371E665C5E003326FB /* Tests */ = { isa = PBXGroup; children = ( + DF66F9D61E8493D400ADB8D5 /* PinScrolling */, 24E654761E68F20400A72A8B /* BothEdgesSnapped */, 2439CC601E665FDE003326FB /* ChainedLayoutView */, 244C6E161E776ACC0074FC74 /* MarginsAndInsets */, @@ -162,7 +167,6 @@ 2439CC651E66610F003326FB /* ValidateConflictsView */, 2439CC641E6660E6003326FB /* ViewExtensionsPositionningView */, ); - name = Tests; path = Tests; sourceTree = ""; }; @@ -312,6 +316,15 @@ path = Domain; sourceTree = ""; }; + DF66F9D61E8493D400ADB8D5 /* PinScrolling */ = { + isa = PBXGroup; + children = ( + DF66F9D81E8493E000ADB8D5 /* PinScrollingView.swift */, + DF66F9D91E8493E000ADB8D5 /* PinScrollingViewController.swift */, + ); + name = PinScrolling; + sourceTree = ""; + }; F143180314A617EFD07C5709 /* Pods */ = { isa = PBXGroup; children = ( @@ -484,6 +497,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + DF66F9DA1E8493E000ADB8D5 /* PinScrollingView.swift in Sources */, 2439CC591E665C6B003326FB /* ValidateConflictsViewController.swift in Sources */, 2439CC571E665C6B003326FB /* ViewExtensionsPositionningViewController.swift in Sources */, 244C6E1A1E776ADB0074FC74 /* MarginsAndInsetsView.swift in Sources */, @@ -506,6 +520,7 @@ 2439CC4D1E665C6B003326FB /* ChainedLayoutViewController.swift in Sources */, 244C6E1B1E776ADB0074FC74 /* MarginsAndInsetsViewController.swift in Sources */, 2439CC511E665C6B003326FB /* MarginsAndPaddingsLeftWidthViewController.swift in Sources */, + DF66F9DB1E8493E000ADB8D5 /* PinScrollingViewController.swift in Sources */, 2439CC521E665C6B003326FB /* MultiRelativeView.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/MCSwiftLayoutSample/MCSwiftLayoutSample/UI/Main/MenuView.swift b/MCSwiftLayoutSample/MCSwiftLayoutSample/UI/Main/MenuView.swift index 30948e54..90b603cb 100644 --- a/MCSwiftLayoutSample/MCSwiftLayoutSample/UI/Main/MenuView.swift +++ b/MCSwiftLayoutSample/MCSwiftLayoutSample/UI/Main/MenuView.swift @@ -36,7 +36,6 @@ class MenuView: UIView { super.layoutSubviews() tableView.layout.size(size) -// tableView.layoutOld.matchView(self) } } diff --git a/MCSwiftLayoutSample/MCSwiftLayoutSample/UI/Main/MenuViewController.swift b/MCSwiftLayoutSample/MCSwiftLayoutSample/UI/Main/MenuViewController.swift index 8615dac7..6032af70 100644 --- a/MCSwiftLayoutSample/MCSwiftLayoutSample/UI/Main/MenuViewController.swift +++ b/MCSwiftLayoutSample/MCSwiftLayoutSample/UI/Main/MenuViewController.swift @@ -39,7 +39,23 @@ enum Page: Int { case .validateConflicts: return "Validate properties conflicts" case .marginsAndInsets: return "Margins and Insets" case .scrollingPin: return "Pin to UIScrollView" - case .count: return "Unknown" + case .count: return "Unknown" + } + } + + var viewController: UIViewController { + switch self { + case .viewExtensionsPositionning: return ViewExtensionsPositionningViewController() + case .relativePositions: return RelativeViewController() + case .multiRelativePositions: return MultiRelativeViewController() + case .chainedLayout: return ChainedLayoutViewController() + case .bothEdgesSnapped: return BothEdgesSnappedViewController() + case .marginsAndPaddingLeftWidth: return MarginsAndPaddingsLeftWidthViewController() + case .marginsAndPaddingLeftRight: return MarginsAndPaddingsLeftRightViewController() + case .validateConflicts: return ValidateConflictsViewController() + case .marginsAndInsets: return MarginsAndInsetsViewController() + case .scrollingPin: return PinScrollingViewController() + case .count: return UIViewController() } } } @@ -71,36 +87,6 @@ class MenuViewController: UIViewController { // MARK: MenuViewDelegate extension MenuViewController: MenuViewDelegate { func didSelect(page: Page) { - var controller: UIViewController? - - switch page { - case .viewExtensionsPositionning: - controller = ViewExtensionsPositionningViewController() - case .relativePositions: - controller = RelativeViewController() - case .multiRelativePositions: - controller = MultiRelativeViewController() - case .chainedLayout: - controller = ChainedLayoutViewController() - case .bothEdgesSnapped: - controller = BothEdgesSnappedViewController() - case .marginsAndPaddingLeftWidth: - controller = MarginsAndPaddingsLeftWidthViewController() - case .marginsAndPaddingLeftRight: - controller = MarginsAndPaddingsLeftRightViewController() - case .validateConflicts: - controller = ValidateConflictsViewController() - case .marginsAndInsets: - controller = MarginsAndInsetsViewController() -// case .scrollingPin: -// controller = - default: - assert(false) - break - } - - if let controller = controller { - navigationController?.pushViewController(controller, animated: true) - } + navigationController?.pushViewController(page.viewController, animated: true) } } diff --git a/MCSwiftLayoutSample/MCSwiftLayoutSample/UI/Tests/BothEdgesSnapped/BothEdgesSnappedView.swift b/MCSwiftLayoutSample/MCSwiftLayoutSample/UI/Tests/BothEdgesSnapped/BothEdgesSnappedView.swift index a0c97de5..2df74df7 100644 --- a/MCSwiftLayoutSample/MCSwiftLayoutSample/UI/Tests/BothEdgesSnapped/BothEdgesSnappedView.swift +++ b/MCSwiftLayoutSample/MCSwiftLayoutSample/UI/Tests/BothEdgesSnapped/BothEdgesSnappedView.swift @@ -95,11 +95,11 @@ class BothEdgesSnappedView: UIView { // addView(leftRightMarginsLeftRightInsetView) } - fileprivate func addView(_ view: BasicView) { - view.layout.height(30).width(70) - contentScrollView.addSubview(view) - } - +// fileprivate func addView(_ view: BasicView) { +// view.layout.height(30).width(70) +// contentScrollView.addSubview(view) +// } + required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) } @@ -129,7 +129,6 @@ class BothEdgesSnappedView: UIView { // bView.layout.above(of: aViewChild, aligned: .right) // expect(bView.frame).to(equal(CGRect(x: 185.0, y: 110.0, width: 40.0, height: 40.0))) - // bView.layout.right(of: aView, aligned: .top) // expect(bView.frame).to(equal(CGRect(x: 300.0, y: 100.0, width: 40.0, height: 40.0))) // bView.layout.right(of: aViewChild, aligned: .top) @@ -145,7 +144,6 @@ class BothEdgesSnappedView: UIView { // bView.layout.right(of: aViewChild, aligned: .bottom) // expect(bView.frame).to(equal(CGRect(x: 225.0, y: 190.0, width: 40.0, height: 40.0))) - // bView.layout.below(of: aView, aligned: .left) // expect(bView.frame).to(equal(CGRect(x: 100.0, y: 260.0, width: 40.0, height: 40.0))) // bView.layout.below(of: aViewChild, aligned: .left) @@ -161,7 +159,6 @@ class BothEdgesSnappedView: UIView { // bView.layout.below(of: aViewChild, aligned: .right) // expect(bView.frame).to(equal(CGRect(x: 185.0, y: 230.0, width: 40.0, height: 40.0))) - // bView.layout.left(of: aView, aligned: .top) // expect(bView.frame).to(equal(CGRect(x: 60.0, y: 100.0, width: 40.0, height: 40.0))) // bView.layout.left(of: aViewChild, aligned: .top) diff --git a/MCSwiftLayoutSample/MCSwiftLayoutSample/UI/Tests/ChainedLayoutView/ChainedLayoutView.swift b/MCSwiftLayoutSample/MCSwiftLayoutSample/UI/Tests/ChainedLayoutView/ChainedLayoutView.swift index 62cee225..b52747d9 100644 --- a/MCSwiftLayoutSample/MCSwiftLayoutSample/UI/Tests/ChainedLayoutView/ChainedLayoutView.swift +++ b/MCSwiftLayoutSample/MCSwiftLayoutSample/UI/Tests/ChainedLayoutView/ChainedLayoutView.swift @@ -64,8 +64,7 @@ class ChainedLayoutView: UIView { override func layoutSubviews() { super.layoutSubviews() - centerView.width = 200 - centerView.height = 200 + centerView.layout.width(200).height(200) centerView.center = CGPoint(x: 200, y: 300) print("topCenterView: \(topCenterView.frame)") diff --git a/MCSwiftLayoutSample/MCSwiftLayoutSample/UI/Tests/MarginsAndInsets/MarginsAndInsetsView.swift b/MCSwiftLayoutSample/MCSwiftLayoutSample/UI/Tests/MarginsAndInsets/MarginsAndInsetsView.swift index 856502c1..0551f207 100644 --- a/MCSwiftLayoutSample/MCSwiftLayoutSample/UI/Tests/MarginsAndInsets/MarginsAndInsetsView.swift +++ b/MCSwiftLayoutSample/MCSwiftLayoutSample/UI/Tests/MarginsAndInsets/MarginsAndInsetsView.swift @@ -98,7 +98,6 @@ class MarginsAndInsetsView: UIView { // TODO: Test using sizeThatFits - // // sizeThatFits // diff --git a/MCSwiftLayoutSample/MCSwiftLayoutSample/UI/Tests/PinScrolling/PinScrollingView.swift b/MCSwiftLayoutSample/MCSwiftLayoutSample/UI/Tests/PinScrolling/PinScrollingView.swift new file mode 100644 index 00000000..dab1a7a3 --- /dev/null +++ b/MCSwiftLayoutSample/MCSwiftLayoutSample/UI/Tests/PinScrolling/PinScrollingView.swift @@ -0,0 +1,67 @@ +// +// PinScrollingView.swift +// MCSwiftLayoutSample +// +// Created by Luc Dion on 2017-03-23. +// Copyright (c) 2017 mcswiftlayyout.mirego.com. All rights reserved. +// +import UIKit + +class PinScrollingView: UIView { + + private let contentScrollView = UIScrollView() + + var aView: BasicView! + var bView: BasicView! + var cView: BasicView! + var dView: BasicView! + + init() { + super.init(frame: .zero) + + backgroundColor = .black + + contentScrollView.backgroundColor = .white + contentScrollView.delegate = self + addSubview(contentScrollView) + + aView = BasicView(text: "View A", color: UIColor.red.withAlphaComponent(0.5)) + contentScrollView.addSubview(aView) + + bView = BasicView(text: "View B", color: UIColor.blue.withAlphaComponent(0.5)) + addSubview(bView) + + cView = BasicView(text: "View C", color: UIColor.red.withAlphaComponent(0.5)) + contentScrollView.addSubview(cView) + + dView = BasicView(text: "View D", color: UIColor.red.withAlphaComponent(0.5)) + contentScrollView.addSubview(dView) + } + + required init?(coder aDecoder: NSCoder) { + super.init(coder: aDecoder) + } + + override func layoutSubviews() { + super.layoutSubviews() + + contentScrollView.layout.pinTopLeft().width(width).height(height).insetTop(64) + contentScrollView.contentSize = CGSize(width: width, height: height * 4) + + aView.layout.top(20).left(0).right(width).height(40).margin(10) + layoutBView() + + cView.layout.below(of: aView, aligned: .right).width(100).height(50).marginTop(10) + dView.layout.below(of: aView, aligned: .left).left(of: cView).height(of: cView).marginTop(10).marginRight(10) + } + + fileprivate func layoutBView() { + bView.layout.pinTopLeft(to: aView.pin.topLeft).pinBottomRight(to: aView.pin.bottomCenter) + } +} + +extension PinScrollingView: UIScrollViewDelegate { + func scrollViewDidScroll(_ scrollView: UIScrollView) { + layoutBView() + } +} diff --git a/MCSwiftLayoutSample/MCSwiftLayoutSample/UI/Tests/PinScrolling/PinScrollingViewController.swift b/MCSwiftLayoutSample/MCSwiftLayoutSample/UI/Tests/PinScrolling/PinScrollingViewController.swift new file mode 100644 index 00000000..057817d6 --- /dev/null +++ b/MCSwiftLayoutSample/MCSwiftLayoutSample/UI/Tests/PinScrolling/PinScrollingViewController.swift @@ -0,0 +1,26 @@ +// +// PinScrollingViewController.swift +// MCSwiftLayoutSample +// +// Created by Luc Dion on 2017-03-23. +// Copyright (c) 2017 mcswiftlayyout.mirego.com. All rights reserved. +// +import UIKit + +class PinScrollingViewController: UIViewController { + fileprivate var mainView: PinScrollingView { + return self.view as! PinScrollingView + } + + init() { + super.init(nibName: nil, bundle: nil) + } + + required init?(coder aDecoder: NSCoder) { + super.init(coder: aDecoder) + } + + override func loadView() { + view = PinScrollingView() + } +} diff --git a/MCSwiftLayoutSample/MCSwiftLayoutSample/UI/Tests/RelativeView/RelativeView.swift b/MCSwiftLayoutSample/MCSwiftLayoutSample/UI/Tests/RelativeView/RelativeView.swift index 2dad13ce..94a27e4b 100644 --- a/MCSwiftLayoutSample/MCSwiftLayoutSample/UI/Tests/RelativeView/RelativeView.swift +++ b/MCSwiftLayoutSample/MCSwiftLayoutSample/UI/Tests/RelativeView/RelativeView.swift @@ -62,8 +62,7 @@ class RelativeView: UIView { fileprivate func addSquare(_ view: UIView, color: UIColor) { view.backgroundColor = color - view.width = 50 - view.height = 50 + view.layout.width(50).height(50) addSubview(view) } diff --git a/MCSwiftLayoutSample/MCSwiftLayoutSample/UI/Tests/ValidateConflictsView/ValidateConflictsView.swift b/MCSwiftLayoutSample/MCSwiftLayoutSample/UI/Tests/ValidateConflictsView/ValidateConflictsView.swift index 3f38be5e..7d7604a2 100644 --- a/MCSwiftLayoutSample/MCSwiftLayoutSample/UI/Tests/ValidateConflictsView/ValidateConflictsView.swift +++ b/MCSwiftLayoutSample/MCSwiftLayoutSample/UI/Tests/ValidateConflictsView/ValidateConflictsView.swift @@ -24,8 +24,7 @@ class ValidateConflictsView: UIView { fileprivate func addSquare(_ view: UIView, color: UIColor) { view.backgroundColor = color - view.width = 50 - view.height = 50 + view.layout.width(50).height(50) addSubview(view) } diff --git a/MCSwiftLayoutSample/MCSwiftLayoutSample/UI/Tests/ViewExtensionsPositionningView/ViewExtensionsPositionningView.swift b/MCSwiftLayoutSample/MCSwiftLayoutSample/UI/Tests/ViewExtensionsPositionningView/ViewExtensionsPositionningView.swift index 99377b5a..796fa6c7 100644 --- a/MCSwiftLayoutSample/MCSwiftLayoutSample/UI/Tests/ViewExtensionsPositionningView/ViewExtensionsPositionningView.swift +++ b/MCSwiftLayoutSample/MCSwiftLayoutSample/UI/Tests/ViewExtensionsPositionningView/ViewExtensionsPositionningView.swift @@ -53,8 +53,7 @@ class ViewExtensionsPositionningView: UIView { fileprivate func addSquare(_ view: UIView, color: UIColor) { view.backgroundColor = color - view.width = 50 - view.height = 50 + view.layout.width(50).height(50) addSubview(view) } @@ -65,8 +64,7 @@ class ViewExtensionsPositionningView: UIView { override func layoutSubviews() { super.layoutSubviews() - centerView.width = 200 - centerView.height = 200 + centerView.layout.width(200).height(200) centerView.center = CGPoint(x: 200, y: 300) print("topCenterView: \(topCenterView.frame)") diff --git a/MCSwiftLayoutTests/AdjustSizeSpec.swift b/MCSwiftLayoutTests/AdjustSizeSpec.swift index 7ee03ee8..25ae6db4 100644 --- a/MCSwiftLayoutTests/AdjustSizeSpec.swift +++ b/MCSwiftLayoutTests/AdjustSizeSpec.swift @@ -62,7 +62,33 @@ class AdjustSizeSpec: QuickSpec { aView.layout.width(35) expect(aView.frame).to(equal(CGRect(x: 140.0, y: 100.0, width: 35, height: 60.0))) } - + + it("should not ajust the width of aView") { + aView.layout.width(-20) + expect(aView.frame).to(equal(CGRect(x: 140.0, y: 100.0, width: 100, height: 60.0))) + } + + it("should ajust the width(percent: CGFloat) of aView") { + aView.layout.width(percent: 50) + expect(aView.frame).to(equal(CGRect(x: 140, y: 100, width: 200, height: 60))) + } + + it("should ajust the width(percent: CGFloat) of aView") { + aView.layout.width(percent: 200) + expect(aView.frame).to(equal(CGRect(x: 140, y: 100, width: 800, height: 60))) + } + + it("should not adjust the width(percent: CGFloat) of aView") { + aView.layout.width(percent: -20) + expect(aView.frame).to(equal(CGRect(x: 140, y: 100, width: 100, height: 60))) + } + + it("should ajust the width(percent: CGFloat) of aView") { + let unAttachedView = UIView(frame: CGRect(x: 10, y: 10, width: 20, height: 30)) + unAttachedView.layout.width(percent: 50) + expect(unAttachedView.frame).to(equal(CGRect(x: 10, y: 10, width: 20, height: 30))) + } + it("should ajust the width of aView") { aView.layout.width(of: aViewChild) expect(aView.frame).to(equal(CGRect(x: 140.0, y: 100.0, width: 50.0, height: 60.0))) @@ -74,7 +100,28 @@ class AdjustSizeSpec: QuickSpec { aView.layout.height(35) expect(aView.frame).to(equal(CGRect(x: 140.0, y: 100.0, width: 100.0, height: 35.0))) } - + + it("should not ajust the height of aView") { + aView.layout.height(-20) + expect(aView.frame).to(equal(CGRect(x: 140.0, y: 100.0, width: 100.0, height: 60.0))) + } + + it("should ajust the width(percent: CGFloat) of aView") { + aView.layout.height(percent: 50) + expect(aView.frame).to(equal(CGRect(x: 140, y: 100, width: 100, height: 200))) + } + + it("should ajust the width(percent: CGFloat) of aView") { + aView.layout.height(percent: 200) + expect(aView.frame).to(equal(CGRect(x: 140, y: 100, width: 100, height: 800))) + } + + it("should ajust the width(percent: CGFloat) of aView") { + let unAttachedView = UIView(frame: CGRect(x: 10, y: 10, width: 20, height: 30)) + unAttachedView.layout.height(percent: 50) + expect(unAttachedView.frame).to(equal(CGRect(x: 10, y: 10, width: 20, height: 30))) + } + it("should ajust the height of aView") { aView.layout.height(of: aViewChild) expect(aView.frame).to(equal(CGRect(x: 140.0, y: 100.0, width: 100.0, height: 30.0))) @@ -103,7 +150,7 @@ class AdjustSizeSpec: QuickSpec { expect(aView.frame).to(equal(CGRect(x: 140.0, y: 100.0, width: 90.0, height: 60.0))) } } - + // // sizeToFit // diff --git a/MCSwiftLayoutTests/MCSwiftLayoutTests.swift b/MCSwiftLayoutTests/MCSwiftLayoutTests.swift index 340761b2..d63472ce 100644 --- a/MCSwiftLayoutTests/MCSwiftLayoutTests.swift +++ b/MCSwiftLayoutTests/MCSwiftLayoutTests.swift @@ -26,6 +26,9 @@ class MCSwiftLayoutTests: XCTestCase { func testExample() { let child1 = UIView() rootView.addSubview(child1) + +// pin(rootView).topLeft(to: child1.pin.center) +// rootView.pin.topLeft(to: child1.pin.center) // child1.layout.pinCenter(of: rootView) // print("child1.frame: \(child1.frame)")