diff --git a/Example/PinLayoutSample/UI/Examples/AutoAdjustingSizeView/AutoAdjustingSizeView.swift b/Example/PinLayoutSample/UI/Examples/AutoAdjustingSizeView/AutoAdjustingSizeView.swift
index 6624a12c..7830c87b 100644
--- a/Example/PinLayoutSample/UI/Examples/AutoAdjustingSizeView/AutoAdjustingSizeView.swift
+++ b/Example/PinLayoutSample/UI/Examples/AutoAdjustingSizeView/AutoAdjustingSizeView.swift
@@ -82,7 +82,7 @@ class AutoAdjustingSizeView: BaseView {
row1Item2.pin.right(of: row1Item1, aligned: .top).bottomRight().margin(0, 2, 2, 2)
row2.pin.below(of: row1, aligned: .left).size(of: row1).marginTop(10)
- row2Item1.pin.top().right().bottom().width(150).width(25%).margin(2)
+ row2Item1.pin.top().bottom().right().width(150).margin(2)
row2Item2.pin.left(of: row2Item1, aligned: .top).left().bottom().margin(0, 2, 2, 2)
row3.pin.below(of: row2, aligned: .left).size(of: row1).marginTop(10)
diff --git a/Example/PinLayoutSample/UI/Examples/Intro/IntroView.swift b/Example/PinLayoutSample/UI/Examples/Intro/IntroView.swift
index 140ae952..07a099fa 100644
--- a/Example/PinLayoutSample/UI/Examples/Intro/IntroView.swift
+++ b/Example/PinLayoutSample/UI/Examples/Intro/IntroView.swift
@@ -62,7 +62,7 @@ class IntroView: BaseView {
let containerInsets = safeArea.minInsets(UIEdgeInsets(top: 10, left: 10, bottom: 0, right: 10))
contentView.pin.all().margin(containerInsets)
- logo.pin.top().left().size(100).aspectRatio().marginTop(10)
+ logo.pin.top().left().width(100).aspectRatio().marginTop(10)
segmented.pin.after(of: logo, aligned: .top).right().marginLeft(10)
textLabel.pin.below(of: segmented, aligned: .left).width(of: segmented).pinEdges().marginTop(10).sizeToFit(.width)
separatorView.pin.below(of: [logo, textLabel], aligned: .left).right(to: segmented.edge.right).marginTop(10)
diff --git a/Example/PinLayoutSample/UI/Examples/IntroObjectiveC/IntroObjectiveCView.m b/Example/PinLayoutSample/UI/Examples/IntroObjectiveC/IntroObjectiveCView.m
index 7a45118a..9e45f61d 100644
--- a/Example/PinLayoutSample/UI/Examples/IntroObjectiveC/IntroObjectiveCView.m
+++ b/Example/PinLayoutSample/UI/Examples/IntroObjectiveC/IntroObjectiveCView.m
@@ -32,6 +32,8 @@ @implementation IntroObjectiveCView {
- (id)initWithFrame:(CGRect)frame {
if ((self = [super initWithFrame:frame])) {
+ Pin.logMissingLayoutCalls = true;
+
topLayoutGuide = 0;
self.backgroundColor = UIColor.whiteColor;
@@ -56,6 +58,10 @@ - (id)initWithFrame:(CGRect)frame {
return self;
}
+- (void)dealloc {
+ Pin.logMissingLayoutCalls = false;
+}
+
- (void) layoutSubviews {
[super layoutSubviews];
diff --git a/Example/PinLayoutSample/UI/Examples/IntroRTL/IntroRTLView.swift b/Example/PinLayoutSample/UI/Examples/IntroRTL/IntroRTLView.swift
index cfb8b552..05f4d277 100644
--- a/Example/PinLayoutSample/UI/Examples/IntroRTL/IntroRTLView.swift
+++ b/Example/PinLayoutSample/UI/Examples/IntroRTL/IntroRTLView.swift
@@ -67,7 +67,7 @@ class IntroRTLView: BaseView {
let containerInsets = safeArea.minInsets(UIEdgeInsets(top: 10, left: 10, bottom: 0, right: 10))
contentView.pin.all().margin(containerInsets)
- logo.pin.top().start().size(100).aspectRatio().marginTop(10)
+ logo.pin.top().start().width(100).aspectRatio().marginTop(10)
segmented.pin.after(of: logo, aligned: .top).end().marginStart(10)
textLabel.pin.below(of: segmented, aligned: .start).width(of: segmented).pinEdges().marginTop(10).sizeToFit(.width)
separatorView.pin.below(of: [logo, textLabel], aligned: .start).end(to: segmented.edge.end).marginTop(10)
diff --git a/PinLayout.xcodeproj/project.pbxproj b/PinLayout.xcodeproj/project.pbxproj
index e38e1cda..876aeb67 100644
--- a/PinLayout.xcodeproj/project.pbxproj
+++ b/PinLayout.xcodeproj/project.pbxproj
@@ -14,6 +14,8 @@
242723731F008BF7006A5C3A /* MinMaxWidthHeightSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 242723711F008B85006A5C3A /* MinMaxWidthHeightSpec.swift */; };
242E8DC31EED5AB2005935FB /* RelativePositionMultipleViewsSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 242E8DC11EED5982005935FB /* RelativePositionMultipleViewsSpec.swift */; };
243B12BC1FC393580072A9C3 /* Percent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 243C620E1FC3834B0082C327 /* Percent.swift */; };
+ 243B12C81FC3D06F0072A9C3 /* LayoutMethodSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 243B12C41FC3CFC10072A9C3 /* LayoutMethodSpec.swift */; };
+ 243B12CB1FC469D00072A9C3 /* ObjectiveCSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 243B12C91FC469550072A9C3 /* ObjectiveCSpec.m */; };
243C62041FC37F680082C327 /* PinLayoutImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2475B6C61FC37C1C0054CADD /* PinLayoutImpl.swift */; };
243C62051FC37F6C0082C327 /* PinLayoutImpl+Coordinates.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2475B6C71FC37C1C0054CADD /* PinLayoutImpl+Coordinates.swift */; };
243C62061FC37F6C0082C327 /* PinLayoutImpl+Layouting.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2475B6C41FC37A900054CADD /* PinLayoutImpl+Layouting.swift */; };
@@ -50,8 +52,8 @@
24BBE6351F50FA1D0091D5E9 /* UnitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24BBE6341F50FA1D0091D5E9 /* UnitTests.swift */; };
24BBE6381F52EC380091D5E9 /* UnitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24BBE6341F50FA1D0091D5E9 /* UnitTests.swift */; };
24D18D171F3B4381008129EF /* RTLSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24D18D151F3B42E0008129EF /* RTLSpec.swift */; };
- 24D18D241F3E37DD008129EF /* PinLayoutGlobals.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24D18D231F3E37DD008129EF /* PinLayoutGlobals.swift */; };
- 24D18D261F3E5EA5008129EF /* PinLayoutGlobals.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24D18D231F3E37DD008129EF /* PinLayoutGlobals.swift */; };
+ 24D18D241F3E37DD008129EF /* Pin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24D18D231F3E37DD008129EF /* Pin.swift */; };
+ 24D18D261F3E5EA5008129EF /* Pin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24D18D231F3E37DD008129EF /* Pin.swift */; };
CA6C7C85508320B18B1FC777 /* Pods_PinLayoutTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 45CE7ABE76F48416DE57DF55 /* Pods_PinLayoutTests.framework */; };
DF7A36BD1E918301000F9856 /* PinEdgesSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF7A36BC1E918301000F9856 /* PinEdgesSpec.swift */; };
DFC97CA71E8A8F2C001545D5 /* PinLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = DFC97CA61E8A8F2C001545D5 /* PinLayout.swift */; };
@@ -86,6 +88,8 @@
241A277C1F8E958F00B1AD39 /* PinLayoutObjCImpl.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PinLayoutObjCImpl.swift; sourceTree = "
-## Using PinLayout with Objective-C
+## PinLayout in Xcode Playgrounds
+
+PinLayout layouts views immediately after the line containing `.pin` has been fully executed, thanks to ARC (Automatic Reference Counting) this works perfectly on iOS/tvOS/macOS simulators and devices. But in Xcode Playgrounds, ARC doesn't work as expected, object references are kept much longer. This is a well documented issue and have a little impact on the PinLayout behaviour.
+
+[See here for more details about using PinLayout in Xcode playgrounds](docs/xcode_playground.md)
+
+
+
+## PinLayout using Objective-C
PinLayout also expose an Objective-C interface slightly different than the Swift interface.
-[See here for more details](docs/objective_c.md).
+[See here for more details](docs/objective_c.md)
diff --git a/Sources/Impl/PinLayoutImpl+Warning.swift b/Sources/Impl/PinLayoutImpl+Warning.swift
index f44f2b8f..71b943dd 100644
--- a/Sources/Impl/PinLayoutImpl+Warning.swift
+++ b/Sources/Impl/PinLayoutImpl+Warning.swift
@@ -52,25 +52,35 @@ extension PinLayoutImpl {
internal func warnPropertyAlreadySet(_ propertyName: String, propertyValue: CGFloat, _ context: Context) {
guard Pin.logWarnings else { return }
- displayWarning("PinLayout Conflict: \(context()) won't be applied since it value has already been set to \(propertyValue).")
+ displayWarning("PinLayout Conflict: \(context()) won't be applied since it value has already been set to \(propertyValue.description).")
}
internal func warnPropertyAlreadySet(_ propertyName: String, propertyValue: CGSize, _ context: Context) {
guard Pin.logWarnings else { return }
- displayWarning("PinLayout Conflict: \(context()) won't be applied since it value has already been set to CGSize(width: \(propertyValue.width), height: \(propertyValue.height)).")
+ displayWarning("PinLayout Conflict: \(context()) won't be applied since it value has already been set to CGSize(width: \(propertyValue.width.description), height: \(propertyValue.height.description)).")
}
internal func warnConflict(_ context: Context, _ properties: [String: Any]) {
guard Pin.logWarnings else { return }
var warning = "PinLayout Conflict: \(context()) won't be applied since it conflicts with the following already set properties:"
properties.forEach { (property) in
- warning += "\n \(property.key): \(property.value)"
+ warning += "\n \(property.key): "
+
+ if let floatValue = property.value as? CGFloat {
+ warning += "\(floatValue.description)"
+ } else {
+ warning += "\(property.value)"
+ }
}
displayWarning(warning)
}
internal func displayLayoutWarnings() {
+ if !Thread.isMainThread {
+ warn("Layout must be executed from the Main Thread!")
+ }
+
if let justify = justify {
func context() -> String { return "justify(.\(justify.description))" }
if !((_left != nil && _right != nil) || (shouldPinEdges && width != nil && (_left != nil || _right != nil || _hCenter != nil))) {
@@ -96,7 +106,7 @@ extension PinLayoutImpl {
internal func displayWarning(_ text: String) {
var displayText = "\n👉 \(text)"
- displayText += "\n (Layouted view info: Type: \(viewName(view)), Frame: \(view.frame)"
+ displayText += "\n(Layouted view info: Type: \(viewName(view)), Frame: \(view.frame)"
var currentView = view
var hierarchy: [String] = []
@@ -111,7 +121,7 @@ extension PinLayoutImpl {
displayText += ", Tag: \(view.tag))\n"
print(displayText)
- _pinlayoutUnitTestLastWarning = text
+ Pin.lastWarningText = text
}
internal func viewDescription(_ view: UIView) -> String {
diff --git a/Sources/Impl/PinLayoutImpl.swift b/Sources/Impl/PinLayoutImpl.swift
index d790e7e6..603ec827 100644
--- a/Sources/Impl/PinLayoutImpl.swift
+++ b/Sources/Impl/PinLayoutImpl.swift
@@ -69,6 +69,9 @@ class PinLayoutImpl: PinLayout {
}
deinit {
+ if !isLayouted && Pin.logMissingLayoutCalls {
+ warn("PinLayout commands have been issued without calling the 'layout()' method to complete the layout. (These warnings can be disabled by setting Pin.logMissingLayoutCalls to false)")
+ }
apply()
}
@@ -88,7 +91,7 @@ class PinLayoutImpl: PinLayout {
@discardableResult
func top(_ percent: Percent) -> PinLayout {
- func context() -> String { return "top(\(percent))" }
+ func context() -> String { return "top(\(percent.description))" }
guard let layoutSuperview = layoutSuperview(context) else { return self }
setTop(percent.of(layoutSuperview.frame.height), context)
return self
@@ -106,7 +109,7 @@ class PinLayoutImpl: PinLayout {
@discardableResult
func left(_ percent: Percent) -> PinLayout {
- return left(percent, { return "left(\(percent))" })
+ return left(percent, { return "left(\(percent.description))" })
}
@discardableResult
@@ -123,7 +126,7 @@ class PinLayoutImpl: PinLayout {
@discardableResult
func start(_ percent: Percent) -> PinLayout {
- func context() -> String { return "start(\(percent))" }
+ func context() -> String { return "start(\(percent.description))" }
return isLTR() ? left(percent, context) : right(percent, context)
}
@@ -138,7 +141,7 @@ class PinLayoutImpl: PinLayout {
@discardableResult
func bottom(_ percent: Percent) -> PinLayout {
- func context() -> String { return "bottom(\(percent))" }
+ func context() -> String { return "bottom(\(percent.description))" }
guard let layoutSuperview = layoutSuperview(context) else { return self }
bottom(percent.of(layoutSuperview.frame.height), context)
return self
@@ -155,7 +158,7 @@ class PinLayoutImpl: PinLayout {
@discardableResult
func right(_ percent: Percent) -> PinLayout {
- return right(percent, { return "right(\(percent))" })
+ return right(percent, { return "right(\(percent.description))" })
}
@discardableResult func end() -> PinLayout {
@@ -171,7 +174,7 @@ class PinLayoutImpl: PinLayout {
@discardableResult
func end(_ percent: Percent) -> PinLayout {
- func context() -> String { return "end(\(percent))" }
+ func context() -> String { return "end(\(percent.description))" }
return isLTR() ? right(percent, context) : left(percent, context)
}
@@ -193,7 +196,7 @@ class PinLayoutImpl: PinLayout {
@discardableResult
func hCenter(_ percent: Percent) -> PinLayout {
- func context() -> String { return "hCenter(\(percent))" }
+ func context() -> String { return "hCenter(\(percent.description))" }
guard let layoutSuperview = layoutSuperview(context) else { return self }
setHorizontalCenter((layoutSuperview.frame.width / 2) + percent.of(layoutSuperview.frame.width), context)
return self
@@ -217,7 +220,7 @@ class PinLayoutImpl: PinLayout {
@discardableResult
func vCenter(_ percent: Percent) -> PinLayout {
- func context() -> String { return "vCenter(\(percent))" }
+ func context() -> String { return "vCenter(\(percent.description))" }
guard let layoutSuperview = layoutSuperview(context) else { return self }
setVerticalCenter((layoutSuperview.frame.height / 2) + percent.of(layoutSuperview.frame.height), context)
return self
@@ -604,7 +607,7 @@ class PinLayoutImpl: PinLayout {
@discardableResult
func width(_ percent: Percent) -> PinLayout {
- func context() -> String { return "width(\(percent))" }
+ func context() -> String { return "width(\(percent.description))" }
guard let layoutSuperview = layoutSuperview(context) else { return self }
return setWidth(percent.of(layoutSuperview.frame.width), context)
}
@@ -622,7 +625,7 @@ class PinLayoutImpl: PinLayout {
@discardableResult
func minWidth(_ percent: Percent) -> PinLayout {
- func context() -> String { return "minWidth(\(percent))" }
+ func context() -> String { return "minWidth(\(percent.description))" }
guard let layoutSuperview = layoutSuperview(context) else { return self }
return setMinWidth(percent.of(layoutSuperview.frame.width), context)
}
@@ -635,7 +638,7 @@ class PinLayoutImpl: PinLayout {
@discardableResult
func maxWidth(_ percent: Percent) -> PinLayout {
- func context() -> String { return "maxWidth(\(percent))" }
+ func context() -> String { return "maxWidth(\(percent.description))" }
guard let layoutSuperview = layoutSuperview(context) else { return self }
return setMaxWidth(percent.of(layoutSuperview.frame.width), context)
}
@@ -647,7 +650,7 @@ class PinLayoutImpl: PinLayout {
@discardableResult
func height(_ percent: Percent) -> PinLayout {
- func context() -> String { return "height(\(percent))" }
+ func context() -> String { return "height(\(percent.description))" }
guard let layoutSuperview = layoutSuperview(context) else { return self }
return setHeight(percent.of(layoutSuperview.frame.height), context)
}
@@ -665,7 +668,7 @@ class PinLayoutImpl: PinLayout {
@discardableResult
func minHeight(_ percent: Percent) -> PinLayout {
- func context() -> String { return "minHeight(\(percent))" }
+ func context() -> String { return "minHeight(\(percent.description))" }
guard let layoutSuperview = layoutSuperview(context) else { return self }
return setMinHeight(percent.of(layoutSuperview.frame.height), context)
}
@@ -678,7 +681,7 @@ class PinLayoutImpl: PinLayout {
@discardableResult
func maxHeight(_ percent: Percent) -> PinLayout {
- func context() -> String { return "maxHeight(\(percent))" }
+ func context() -> String { return "maxHeight(\(percent.description))" }
guard let layoutSuperview = layoutSuperview(context) else { return self }
return setMaxHeight(percent.of(layoutSuperview.frame.height), context)
}
@@ -698,7 +701,7 @@ class PinLayoutImpl: PinLayout {
@discardableResult
func size(_ percent: Percent) -> PinLayout {
- func context() -> String { return "size(\(percent))" }
+ func context() -> String { return "size(\(percent.description))" }
guard let layoutSuperview = layoutSuperview(context) else { return self }
let size = CGSize(width: percent.of(layoutSuperview.frame.width), height: percent.of(layoutSuperview.frame.height))
return setSize(size, context)
diff --git a/Sources/Impl/TypesImpl.swift b/Sources/Impl/TypesImpl.swift
index 13d6168f..c7ada4a5 100644
--- a/Sources/Impl/TypesImpl.swift
+++ b/Sources/Impl/TypesImpl.swift
@@ -182,7 +182,21 @@ extension Percent {
return rhs * value / 100
}
public var description: String {
- return "\(value)%"
+ if value.truncatingRemainder(dividingBy: 1) == 0.0 {
+ return "\(Int(value))%"
+ } else {
+ return "\(value)%"
+ }
+ }
+}
+
+extension CGFloat {
+ public var description: String {
+ if self.truncatingRemainder(dividingBy: 1) == 0.0 {
+ return "\(Int(self))"
+ } else {
+ return "\(self)"
+ }
}
}
diff --git a/Sources/Impl/UnitTests.swift b/Sources/Impl/UnitTests.swift
index 19edab05..d02c75a7 100644
--- a/Sources/Impl/UnitTests.swift
+++ b/Sources/Impl/UnitTests.swift
@@ -19,8 +19,6 @@
import UIKit
-public var _pinlayoutUnitTestLastWarning: String?
-
public func _pinlayoutSetUnitTest(displayScale: CGFloat) {
Coordinates.displayScale = displayScale
}
diff --git a/Sources/ObjectiveC/PinLayoutObjCImpl.swift b/Sources/ObjectiveC/PinLayoutObjCImpl.swift
index 8a3efc19..ff31d234 100644
--- a/Sources/ObjectiveC/PinLayoutObjCImpl.swift
+++ b/Sources/ObjectiveC/PinLayoutObjCImpl.swift
@@ -36,6 +36,7 @@ import UIKit
public func layout() {
// With objective-c PinLayoutObjCImpl instance are sometimes deallocated only after the context has been quit. For this reason
// developpers must call the layout: method implicetely.
+ impl?.layout()
impl = nil
}
diff --git a/Sources/PinLayoutGlobals.swift b/Sources/Pin.swift
similarity index 65%
rename from Sources/PinLayoutGlobals.swift
rename to Sources/Pin.swift
index eecc4fb5..0689758d 100644
--- a/Sources/PinLayoutGlobals.swift
+++ b/Sources/Pin.swift
@@ -25,18 +25,26 @@ public enum LayoutDirection {
case rtl
}
-public class PinLayoutGlobals {
- public var layoutDirection = LayoutDirection.ltr
+@objc public class Pin: NSObject {
+ public static var layoutDirection = LayoutDirection.ltr
#if DEBUG
- public var logWarnings = true
+ public static var logWarnings = true
#else
- public var logWarnings = false
+ public static var logWarnings = false
#endif
- public func layoutDirection(_ direction: LayoutDirection) {
+ /**
+ If your codes need to work in Xcode playgrounds, you may set to `true` the property
+ `Pin.logMissingLayoutCalls`, this way any missing call to `layout()` will generate
+ a warning in the Xcode console..
+ */
+ public static var logMissingLayoutCalls = false
+
+ public static func layoutDirection(_ direction: LayoutDirection) {
self.layoutDirection = direction
}
+
+ // Contains PinLayout last warning's text. Used by PinLayout's Unit Tests.
+ public static var lastWarningText: String?
}
-
-public let Pin = PinLayoutGlobals()
diff --git a/Sources/PinLayout.swift b/Sources/PinLayout.swift
index 0b645d36..10b1059f 100644
--- a/Sources/PinLayout.swift
+++ b/Sources/PinLayout.swift
@@ -118,8 +118,6 @@ public extension UIView {
/// PinLayout interface
public protocol PinLayout {
- func layout()
-
//
// MARK: Layout using distances from superview’s edges
//
@@ -484,6 +482,18 @@ public protocol PinLayout {
///
/// - Returns: PinLayout
@discardableResult func pinEdges() -> PinLayout
+
+ /**
+ The method will execute PinLayout commands immediately. This method is **required only if your
+ source codes should also work in Xcode Playgrounds**. Outside of playgrounds, PinLayout executes
+ this method implicitly, it is not necessary to call it.
+
+ Examples:
+ ```swift
+ view.pin.top(20).width(100).layout()
+ ```
+ */
+ func layout()
}
/// Horizontal alignment used with relative positionning methods: above(of relativeView:, aligned:), below(of relativeView:, aligned:)
diff --git a/Tests/AdjustSizeSpec.swift b/Tests/AdjustSizeSpec.swift
index ebe9bd69..a0f5ee1c 100644
--- a/Tests/AdjustSizeSpec.swift
+++ b/Tests/AdjustSizeSpec.swift
@@ -49,7 +49,7 @@ class AdjustSizeSpec: QuickSpec {
}
beforeEach {
- _pinlayoutUnitTestLastWarning = nil
+ Pin.lastWarningText = nil
viewController = UIViewController()
@@ -167,13 +167,13 @@ class AdjustSizeSpec: QuickSpec {
it("should warn that size()'s width won't be applied") {
aView.pin.width(90).size(CGSize(width: 25, height: 25))
expect(aView.frame).to(equal(CGRect(x: 140.0, y: 100.0, width: 90.0, height: 25.0)))
- expect(_pinlayoutUnitTestLastWarning).to(contain(["size", "width", "won't be applied", "value has already been set"]))
+ expect(Pin.lastWarningText).to(contain(["size", "width", "won't be applied", "value has already been set"]))
}
it("should warn that size()'s height won't be applied") {
aView.pin.height(90).size(CGSize(width: 25, height: 25))
expect(aView.frame).to(equal(CGRect(x: 140.0, y: 100.0, width: 25.0, height: 90.0)))
- expect(_pinlayoutUnitTestLastWarning).to(contain(["size", "height", "won't be applied", "value has already been set"]))
+ expect(Pin.lastWarningText).to(contain(["size", "height", "won't be applied", "value has already been set"]))
}
it("should adjust the size of aView by calling a size(...) method") {
@@ -184,19 +184,19 @@ class AdjustSizeSpec: QuickSpec {
it("should warn that size(of)'s width won't be applied") {
aView.pin.width(90).size(of: aViewChild)
expect(aView.frame).to(equal(CGRect(x: 140.0, y: 100.0, width: 90.0, height: 30.0)))
- expect(_pinlayoutUnitTestLastWarning).to(contain(["size", "width", "won't be applied", "value has already been set"]))
+ expect(Pin.lastWarningText).to(contain(["size", "width", "won't be applied", "value has already been set"]))
}
it("should warn that size()'s width won't be applied") {
aView.pin.width(90).size(20)
expect(aView.frame).to(equal(CGRect(x: 140.0, y: 100.0, width: 90.0, height: 20.0)))
- expect(_pinlayoutUnitTestLastWarning).to(contain(["size", "width", "won't be applied", "value has already been set"]))
+ expect(Pin.lastWarningText).to(contain(["size", "width", "won't be applied", "value has already been set"]))
}
it("should warn that size()'s width won't be applied") {
aView.pin.width(90).size(50%)
expect(aView.frame).to(equal(CGRect(x: 140.0, y: 100.0, width: 90.0, height: 200.0)))
- expect(_pinlayoutUnitTestLastWarning).to(contain(["size", "width", "won't be applied", "value has already been set"]))
+ expect(Pin.lastWarningText).to(contain(["size", "width", "won't be applied", "value has already been set"]))
}
}
@@ -206,7 +206,7 @@ class AdjustSizeSpec: QuickSpec {
describe("the result of the fitSize() method") {
it("should not adjust the size of aView if width or height has not been specified") {
aView.pin.fitSize()
- expect(_pinlayoutUnitTestLastWarning).to(contain(["fitSize() won't be applied", "neither the width nor the height can be determined"]))
+ expect(Pin.lastWarningText).to(contain(["fitSize() won't be applied", "neither the width nor the height can be determined"]))
expect(aView.frame).to(equal(CGRect(x: 140.0, y: 100.0, width: 100.0, height: 60.0)))
}
@@ -608,29 +608,29 @@ class AdjustSizeSpec: QuickSpec {
describe("the result of the sizeToFit(.height) && sizeToFit(.width)") {
it("should warn method") {
aView.pin.width(100).fitSize().sizeToFit(.width)
- expect(_pinlayoutUnitTestLastWarning).to(contain(["sizeToFit(.width)", "won't be applied", "conflicts with fitSize()"]))
+ expect(Pin.lastWarningText).to(contain(["sizeToFit(.width)", "won't be applied", "conflicts with fitSize()"]))
expect(aView.frame).to(equal(CGRect(x: 140.0, y: 100.0, width: 100.0, height: 16.0)))
}
it("should warn method") {
aView.pin.width(100).fitSize().sizeToFit(.height)
- expect(_pinlayoutUnitTestLastWarning).to(contain(["sizeToFit(.height)", "won't be applied", "conflicts with fitSize()"]))
+ expect(Pin.lastWarningText).to(contain(["sizeToFit(.height)", "won't be applied", "conflicts with fitSize()"]))
expect(aView.frame).to(equal(CGRect(x: 140.0, y: 100.0, width: 100.0, height: 16.0)))
}
it("should warn method") {
aView.pin.width(100).aspectRatio(2).sizeToFit(.width)
- expect(_pinlayoutUnitTestLastWarning).to(contain(["sizeToFit(.width)", "won't be applied", "aspectRatio: 2"]))
+ expect(Pin.lastWarningText).to(contain(["sizeToFit(.width)", "won't be applied", "aspectRatio: 2"]))
}
it("should warn method") {
aView.pin.sizeToFit(.width).aspectRatio(2)
- expect(_pinlayoutUnitTestLastWarning).to(contain([" aspectRatio(2.0)", "won't be applied", "conflicts with sizeToFit(.width)"]))
+ expect(Pin.lastWarningText).to(contain([" aspectRatio(2.0)", "won't be applied", "conflicts with sizeToFit(.width)"]))
}
it("should warn method") {
aView.pin.width(100).fitSize().aspectRatio(2)
- expect(_pinlayoutUnitTestLastWarning).to(contain([" aspectRatio(2.0)", "won't be applied", "conflicts with fitSize()"]))
+ expect(Pin.lastWarningText).to(contain([" aspectRatio(2.0)", "won't be applied", "conflicts with fitSize()"]))
}
}
diff --git a/Tests/AspectRatioTests.swift b/Tests/AspectRatioTests.swift
index 833905b4..a73f4f50 100644
--- a/Tests/AspectRatioTests.swift
+++ b/Tests/AspectRatioTests.swift
@@ -42,7 +42,7 @@ class AspectRatioTests: QuickSpec {
}
beforeEach {
- _pinlayoutUnitTestLastWarning = nil
+ Pin.lastWarningText = nil
viewController = UIViewController()
@@ -69,54 +69,54 @@ class AspectRatioTests: QuickSpec {
describe("the result of the aspectRatio(CGFloat)") {
it("should warn about fitSize()") {
aView.pin.left().width(100%).aspectRatio(2).fitSize()
- expect(_pinlayoutUnitTestLastWarning).to(contain(["fitSize() won't be applied", "conflicts", "aspectRatio"]))
+ expect(Pin.lastWarningText).to(contain(["fitSize() won't be applied", "conflicts", "aspectRatio"]))
}
it("should warn about fitSize()") {
aView.pin.left().height(100).aspectRatio(2).fitSize()
- expect(_pinlayoutUnitTestLastWarning).to(contain(["fitSize() won't be applied", "conflicts", "aspectRatio"]))
+ expect(Pin.lastWarningText).to(contain(["fitSize() won't be applied", "conflicts", "aspectRatio"]))
}
it("should warn about aspectRatio(:CGFloat)") {
aView.sizeThatFitsExpectedArea = 40 * 40
aView.pin.left().width(100%).fitSize().aspectRatio(2)
- expect(_pinlayoutUnitTestLastWarning).to(contain(["aspectRatio(2.0) won't be applied", "conflicts", "fitSize()"]))
+ expect(Pin.lastWarningText).to(contain(["aspectRatio(2.0) won't be applied", "conflicts", "fitSize()"]))
}
it("should warn about aspectRatio(:CGFloat)") {
aView.sizeThatFitsExpectedArea = 40 * 40
aView.pin.left().height(100).fitSize().aspectRatio(2)
- expect(_pinlayoutUnitTestLastWarning).to(contain(["aspectRatio(2.0) won't be applied", "conflicts", "fitSize"]))
+ expect(Pin.lastWarningText).to(contain(["aspectRatio(2.0) won't be applied", "conflicts", "fitSize"]))
expect(aView.frame).to(equal(CGRect(x: 0.0, y: 100.0, width: 16.0, height: 100.0)))
}
it("should warn about aspectRatio(:CGFloat)") {
aView.pin.left().aspectRatio(2)
- expect(_pinlayoutUnitTestLastWarning).to(contain(["aspectRatio won't be applied", "neither the width nor the height can be determined"]))
+ expect(Pin.lastWarningText).to(contain(["aspectRatio won't be applied", "neither the width nor the height can be determined"]))
expect(aView.frame).to(equal(CGRect(x: 0.0, y: 100.0, width: 200.0, height: 100.0)))
}
it("should warn about aspectRatio(:CGFloat)") {
aView.pin.left().width(100%).aspectRatio(-2)
- expect(_pinlayoutUnitTestLastWarning).to(contain(["aspectRatio", "won't be applied", "must be greater than zero"]))
+ expect(Pin.lastWarningText).to(contain(["aspectRatio", "won't be applied", "must be greater than zero"]))
expect(aView.frame).to(equal(CGRect(x: 0.0, y: 100.0, width: 400.0, height: 100.0)))
}
it("should warn about aspectRatio(:CGFloat)") {
aView.pin.left().height(100).aspectRatio(-2)
- expect(_pinlayoutUnitTestLastWarning).to(contain(["aspectRatio", "won't be applied", "must be greater than zero"]))
+ expect(Pin.lastWarningText).to(contain(["aspectRatio", "won't be applied", "must be greater than zero"]))
expect(aView.frame).to(equal(CGRect(x: 0.0, y: 100.0, width: 200.0, height: 100.0)))
}
it("should warn about aspectRatio(:CGFloat)") {
aView.pin.left().width(100%).aspectRatio(0)
- expect(_pinlayoutUnitTestLastWarning).to(contain(["aspectRatio", "won't be applied", "must be greater than zero"]))
+ expect(Pin.lastWarningText).to(contain(["aspectRatio", "won't be applied", "must be greater than zero"]))
expect(aView.frame).to(equal(CGRect(x: 0.0, y: 100.0, width: 400.0, height: 100.0)))
}
it("should warn about aspectRatio(:CGFloat)") {
aView.pin.left().height(100).aspectRatio(0)
- expect(_pinlayoutUnitTestLastWarning).to(contain(["aspectRatio", "won't be applied", "must be greater than zero"]))
+ expect(Pin.lastWarningText).to(contain(["aspectRatio", "won't be applied", "must be greater than zero"]))
expect(aView.frame).to(equal(CGRect(x: 0.0, y: 100.0, width: 200.0, height: 100.0)))
}
@@ -165,13 +165,13 @@ class AspectRatioTests: QuickSpec {
describe("the result of the aspectRatio(CGFloat)") {
it("should warn about aspectRatio()") {
aView.pin.left().width(100).aspectRatio()
- expect(_pinlayoutUnitTestLastWarning).to(contain(["aspectRatio() won't be applied", "the layouted must be an UIImageView()"]))
+ expect(Pin.lastWarningText).to(contain(["aspectRatio() won't be applied", "the layouted must be an UIImageView()"]))
expect(aView.frame).to(equal(CGRect(x: 0.0, y: 100.0, width: 100.0, height: 100.0)))
}
it("should warn about aspectRatio()") {
imageView.pin.left().aspectRatio()
- expect(_pinlayoutUnitTestLastWarning).to(contain(["aspectRatio won't be applied", "neither the width nor the height can be determined"]))
+ expect(Pin.lastWarningText).to(contain(["aspectRatio won't be applied", "neither the width nor the height can be determined"]))
expect(imageView.frame).to(equal(CGRect(x: 0.0, y: 10.0, width: 60.0, height: 60.0)))
}
diff --git a/Tests/JustifyAlignSpec.swift b/Tests/JustifyAlignSpec.swift
index e72e5603..39c00e4c 100644
--- a/Tests/JustifyAlignSpec.swift
+++ b/Tests/JustifyAlignSpec.swift
@@ -38,7 +38,7 @@ class JustifyAlignSpec: QuickSpec {
}
beforeEach {
- _pinlayoutUnitTestLastWarning = nil
+ Pin.lastWarningText = nil
viewController = UIViewController()
@@ -59,31 +59,31 @@ class JustifyAlignSpec: QuickSpec {
it("test when missing left and right coordinate") {
aView.pin.justify(.center)
expect(aView.frame).to(equal(CGRect(x: 40.0, y: 100.0, width: 100.0, height: 60.0)))
- expect(_pinlayoutUnitTestLastWarning).to(contain(["justify", "center", "won't be applied", "left and right"]))
+ expect(Pin.lastWarningText).to(contain(["justify", "center", "won't be applied", "left and right"]))
}
it("test when missing left and right coordinate") {
aView.pin.width(100).justify(.center)
expect(aView.frame).to(equal(CGRect(x: 40.0, y: 100.0, width: 100.0, height: 60.0)))
- expect(_pinlayoutUnitTestLastWarning).to(contain(["justify", "center", "won't be applied", "left and right"]))
+ expect(Pin.lastWarningText).to(contain(["justify", "center", "won't be applied", "left and right"]))
}
it("test when missing left and right coordinate") {
aView.pin.left().pinEdges().justify(.center)
expect(aView.frame).to(equal(CGRect(x: 0.0, y: 100.0, width: 100.0, height: 60.0)))
- expect(_pinlayoutUnitTestLastWarning).to(contain(["justify", "center", "won't be applied", "left and right"]))
+ expect(Pin.lastWarningText).to(contain(["justify", "center", "won't be applied", "left and right"]))
}
it("test when missing right coordinate") {
aView.pin.left().width(250).justify(.center)
expect(aView.frame).to(equal(CGRect(x: 0.0, y: 100.0, width: 250.0, height: 60.0)))
- expect(_pinlayoutUnitTestLastWarning).to(contain(["justify", "center", "won't be applied", "left and right"]))
+ expect(Pin.lastWarningText).to(contain(["justify", "center", "won't be applied", "left and right"]))
}
it("test when hCenter has been set and justify() won't be applied") {
aView.pin.hCenter(60).justify(.center)
expect(aView.frame).to(equal(CGRect(x: 210.0, y: 100.0, width: 100.0, height: 60.0)))
- expect(_pinlayoutUnitTestLastWarning).to(contain(["justify", "center", "won't be applied", "hCenter"]))
+ expect(Pin.lastWarningText).to(contain(["justify", "center", "won't be applied", "hCenter"]))
}
}
@@ -94,31 +94,31 @@ class JustifyAlignSpec: QuickSpec {
it("test when missing top and bottom coordinate") {
aView.pin.align(.center)
expect(aView.frame).to(equal(CGRect(x: 40.0, y: 100.0, width: 100.0, height: 60.0)))
- expect(_pinlayoutUnitTestLastWarning).to(contain(["align(.center)", "won't be applied", "top and bottom"]))
+ expect(Pin.lastWarningText).to(contain(["align(.center)", "won't be applied", "top and bottom"]))
}
it("test when missing left and right coordinate") {
aView.pin.width(100).align(.center)
expect(aView.frame).to(equal(CGRect(x: 40.0, y: 100.0, width: 100.0, height: 60.0)))
- expect(_pinlayoutUnitTestLastWarning).to(contain(["align(.center)", "won't be applied", "top and bottom"]))
+ expect(Pin.lastWarningText).to(contain(["align(.center)", "won't be applied", "top and bottom"]))
}
it("test when missing left and right coordinate") {
aView.pin.left().pinEdges().align(.center)
expect(aView.frame).to(equal(CGRect(x: 0.0, y: 100.0, width: 100.0, height: 60.0)))
- expect(_pinlayoutUnitTestLastWarning).to(contain(["align(.center)", "won't be applied", "top and bottom"]))
+ expect(Pin.lastWarningText).to(contain(["align(.center)", "won't be applied", "top and bottom"]))
}
it("test when missing right coordinate") {
aView.pin.left().width(250).align(.center)
expect(aView.frame).to(equal(CGRect(x: 0.0, y: 100.0, width: 250.0, height: 60.0)))
- expect(_pinlayoutUnitTestLastWarning).to(contain(["align(.center)", "won't be applied", "top and bottom"]))
+ expect(Pin.lastWarningText).to(contain(["align(.center)", "won't be applied", "top and bottom"]))
}
it("test when hCenter has been set and align() won't be applied") {
aView.pin.hCenter(60).align(.center)
expect(aView.frame).to(equal(CGRect(x: 210.0, y: 100.0, width: 100.0, height: 60.0)))
- expect(_pinlayoutUnitTestLastWarning).to(contain(["align(.center)", "won't be applied", "top and bottom"]))
+ expect(Pin.lastWarningText).to(contain(["align(.center)", "won't be applied", "top and bottom"]))
}
}
diff --git a/Tests/LayoutMethodSpec.swift b/Tests/LayoutMethodSpec.swift
new file mode 100644
index 00000000..8356b089
--- /dev/null
+++ b/Tests/LayoutMethodSpec.swift
@@ -0,0 +1,82 @@
+// Copyright (c) 2017 Luc Dion
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+import Quick
+import Nimble
+import PinLayout
+
+class LayoutMethodSpec: QuickSpec {
+ override func spec() {
+ var viewController: UIViewController!
+ var rootView: BasicView!
+ var aView: BasicView!
+
+ /*
+ root
+ |
+ - aView
+ */
+
+ beforeSuite {
+ _pinlayoutSetUnitTest(displayScale: 2)
+ }
+
+ beforeEach {
+ Pin.lastWarningText = nil
+ Pin.logMissingLayoutCalls = false
+
+ viewController = UIViewController()
+
+ rootView = BasicView(text: "", color: .white)
+ rootView.frame = CGRect(x: 0, y: 0, width: 400, height: 400)
+ viewController.view.addSubview(rootView)
+
+ aView = BasicView(text: "View A", color: UIColor.red.withAlphaComponent(0.5))
+ aView.frame = CGRect(x: 40, y: 100, width: 100, height: 60)
+ rootView.addSubview(aView)
+ }
+
+ afterEach {
+ Pin.logMissingLayoutCalls = false
+ }
+
+ //
+ // layout()
+ //
+ describe("layout()") {
+ it("test layout() method") {
+ let aViewFrame = aView.frame
+ aView.pin.left().right()
+ expect(aView.frame).to(equal(CGRect(x: 0.0, y: 100.0, width: 400.0, height: 60.0)))
+ expect(Pin.lastWarningText).to(beNil())
+
+ aView.frame = aViewFrame
+ aView.pin.left().right().layout()
+ expect(aView.frame).to(equal(CGRect(x: 0.0, y: 100.0, width: 400.0, height: 60.0)))
+ }
+
+ it("should warn if layout() is not called when Pin.logMissingLayoutCalls is set to true") {
+ Pin.logMissingLayoutCalls = true
+
+ aView.pin.left().right()
+ expect(Pin.lastWarningText).to(contain(["PinLayout commands have been issued without calling the 'layout()' method"]))
+ }
+ }
+ }
+}
diff --git a/Tests/MinMaxWidthHeightSpec.swift b/Tests/MinMaxWidthHeightSpec.swift
index 90cf879d..fd260363 100644
--- a/Tests/MinMaxWidthHeightSpec.swift
+++ b/Tests/MinMaxWidthHeightSpec.swift
@@ -38,7 +38,7 @@ class MinMaxWidthHeightSpec: QuickSpec {
}
beforeEach {
- _pinlayoutUnitTestLastWarning = nil
+ Pin.lastWarningText = nil
viewController = UIViewController()
@@ -122,7 +122,7 @@ class MinMaxWidthHeightSpec: QuickSpec {
it("should adjust the width when using hCenter") {
aView.pin.hCenter().width(20).minWidth(250).justify(.left)
expect(aView.frame).to(equal(CGRect(x: 75.0, y: 100.0, width: 250.0, height: 60.0)))
- expect(_pinlayoutUnitTestLastWarning).to(contain(["justify(.left)", "won't be applied", "justification is not applied when hCenter has been set"]))
+ expect(Pin.lastWarningText).to(contain(["justify(.left)", "won't be applied", "justification is not applied when hCenter has been set"]))
}
}
@@ -203,25 +203,25 @@ class MinMaxWidthHeightSpec: QuickSpec {
it("should adjust the width using justify") {
aView.pin.left().width(100%).maxWidth(250).justify(.center)
expect(aView.frame).to(equal(CGRect(x: 0.0, y: 100.0, width: 250.0, height: 60.0)))
- expect(_pinlayoutUnitTestLastWarning).to(contain(["justify(.center)", "won't be applied", "left and right coordinates"]))
+ expect(Pin.lastWarningText).to(contain(["justify(.center)", "won't be applied", "left and right coordinates"]))
}
it("should adjust the width using justify") {
aView.pin.left().width(100%).maxWidth(250).justify(.right)
expect(aView.frame).to(equal(CGRect(x: 0.0, y: 100.0, width: 250.0, height: 60.0)))
- expect(_pinlayoutUnitTestLastWarning).to(contain(["justify(.right)", "won't be applied", "left and right coordinates"]))
+ expect(Pin.lastWarningText).to(contain(["justify(.right)", "won't be applied", "left and right coordinates"]))
}
it("should adjust the width using justify") {
aView.pin.right().width(100%).maxWidth(250).justify(.left)
expect(aView.frame).to(equal(CGRect(x: 150.0, y: 100.0, width: 250.0, height: 60.0)))
- expect(_pinlayoutUnitTestLastWarning).to(contain(["justify(.left)", "won't be applied", "left and right coordinates"]))
+ expect(Pin.lastWarningText).to(contain(["justify(.left)", "won't be applied", "left and right coordinates"]))
}
it("should adjust the width using justify") {
aView.pin.right().width(100%).maxWidth(250).justify(.center)
expect(aView.frame).to(equal(CGRect(x: 150.0, y: 100.0, width: 250.0, height: 60.0)))
- expect(_pinlayoutUnitTestLastWarning).to(contain(["justify(.center)", "won't be applied", "left and right coordinates"]))
+ expect(Pin.lastWarningText).to(contain(["justify(.center)", "won't be applied", "left and right coordinates"]))
}
it("should adjust the width using justify") {
@@ -414,7 +414,7 @@ class MinMaxWidthHeightSpec: QuickSpec {
it("should adjust the height when using hCenter") {
aView.pin.vCenter().height(20).minHeight(250).align(.top)
expect(aView.frame).to(equal(CGRect(x: 40.0, y: 75.0, width: 100.0, height: 250.0)))
- expect(_pinlayoutUnitTestLastWarning).to(contain(["align(.top)", "won't be applied", "alignment is not applied when vCenter has been set"]))
+ expect(Pin.lastWarningText).to(contain(["align(.top)", "won't be applied", "alignment is not applied when vCenter has been set"]))
}
}
@@ -490,37 +490,37 @@ class MinMaxWidthHeightSpec: QuickSpec {
it("should adjust the height using align") {
aView.pin.top().height(100%).maxHeight(250).align(.top)
expect(aView.frame).to(equal(CGRect(x: 40.0, y: 00.0, width: 100.0, height: 250.0)))
- expect(_pinlayoutUnitTestLastWarning).to(contain(["align(.top)", "won't be applied", "top and bottom coordinates"]))
+ expect(Pin.lastWarningText).to(contain(["align(.top)", "won't be applied", "top and bottom coordinates"]))
}
it("should adjust the height using align") {
aView.pin.top().height(100%).maxHeight(250).align(.center)
expect(aView.frame).to(equal(CGRect(x: 40.0, y: 0.0, width: 100.0, height: 250.0)))
- expect(_pinlayoutUnitTestLastWarning).to(contain(["align(.center)", "won't be applied", "top and bottom coordinates"]))
+ expect(Pin.lastWarningText).to(contain(["align(.center)", "won't be applied", "top and bottom coordinates"]))
}
it("should adjust the height using align") {
aView.pin.top().height(100%).maxHeight(250).align(.bottom)
expect(aView.frame).to(equal(CGRect(x: 40.0, y: 00.0, width: 100.0, height: 250.0)))
- expect(_pinlayoutUnitTestLastWarning).to(contain(["align(.bottom)", "won't be applied", "top and bottom coordinates"]))
+ expect(Pin.lastWarningText).to(contain(["align(.bottom)", "won't be applied", "top and bottom coordinates"]))
}
it("should adjust the height using align") {
aView.pin.bottom().height(100%).maxHeight(250).align(.top)
expect(aView.frame).to(equal(CGRect(x: 40.0, y: 150.0, width: 100.0, height: 250.0)))
- expect(_pinlayoutUnitTestLastWarning).to(contain(["align(.top)", "won't be applied", "top and bottom coordinates"]))
+ expect(Pin.lastWarningText).to(contain(["align(.top)", "won't be applied", "top and bottom coordinates"]))
}
it("should adjust the height using align") {
aView.pin.bottom().height(100%).maxHeight(250).align(.center)
expect(aView.frame).to(equal(CGRect(x: 40.0, y: 150.0, width: 100.0, height: 250.0)))
- expect(_pinlayoutUnitTestLastWarning).to(contain(["align(.center)", "won't be applied", "top and bottom coordinates"]))
+ expect(Pin.lastWarningText).to(contain(["align(.center)", "won't be applied", "top and bottom coordinates"]))
}
it("should adjust the height using align") {
aView.pin.bottom().height(100%).maxHeight(250).align(.bottom)
expect(aView.frame).to(equal(CGRect(x: 40.0, y: 150.0, width: 100.0, height: 250.0)))
- expect(_pinlayoutUnitTestLastWarning).to(contain(["align(.bottom)", "won't be applied", "top and bottom coordinates"]))
+ expect(Pin.lastWarningText).to(contain(["align(.bottom)", "won't be applied", "top and bottom coordinates"]))
}
it("should adjust the height using align") {
diff --git a/Tests/ObjectiveCSpec.m b/Tests/ObjectiveCSpec.m
new file mode 100644
index 00000000..c93cab97
--- /dev/null
+++ b/Tests/ObjectiveCSpec.m
@@ -0,0 +1,63 @@
+//
+// ObjectiveCSpec.m
+// PinLayout
+//
+// Created by DION, Luc (MTL) on 2017-11-21.
+// Copyright © 2017 mcswiftlayyout.mirego.com. All rights reserved.
+//
+
+#import
+
+