Skip to content

Commit 7108208

Browse files
author
Luc Dion
committed
Implementation of relative positioning using multiple relative views
1 parent 27f5518 commit 7108208

File tree

7 files changed

+293
-182
lines changed

7 files changed

+293
-182
lines changed

Example/PinLayoutSample/UI/Tests/MultiRelativeView/MultiRelativeView.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
import UIKit
2929

3030
class MultiRelativeView: UIView {
31-
private let view1 = BasicView(text: "View1", color: UIColor.blue.withAlphaComponent(0.6))
32-
private let view2 = BasicView(text: "View2", color: UIColor.blue.withAlphaComponent(0.6))
33-
private let view = BasicView(text: "View", color: UIColor.blue.withAlphaComponent(1.0))
31+
fileprivate let view1 = BasicView(text: "View1", color: UIColor.blue.withAlphaComponent(0.6))
32+
fileprivate let view2 = BasicView(text: "View2", color: UIColor.blue.withAlphaComponent(0.6))
33+
fileprivate let view = BasicView(text: "View", color: UIColor.blue.withAlphaComponent(1.0))
3434

3535
init() {
3636
super.init(frame: .zero)

Example/PinLayoutSample/UI/Tests/PinScrolling/PinScrollingView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import PinLayout
3030

3131
class PinScrollingView: UIView {
3232

33-
private let contentScrollView = UIScrollView()
33+
fileprivate let contentScrollView = UIScrollView()
3434

3535
var aView: BasicView!
3636
var bView: BasicView!

Example/PinLayoutSample/UI/Tests/RelativeView/RelativeView.swift

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,26 @@ class RelativeView: UIView {
3333

3434
var rootView: BasicView!
3535

36-
private let centerView = UIView()
36+
fileprivate let centerView = UIView()
3737

38-
private let topLeftView = UIView()
39-
private let topCenterView = UIView()
40-
private let topRightView = UIView()
38+
fileprivate let topLeftView = UIView()
39+
fileprivate let topCenterView = UIView()
40+
fileprivate let topRightView = UIView()
4141

42-
private let leftTopView = UIView()
43-
private let leftCenterView = UIView()
44-
private let leftBottomView = UIView()
42+
fileprivate let leftTopView = UIView()
43+
fileprivate let leftCenterView = UIView()
44+
fileprivate let leftBottomView = UIView()
4545

46-
private let bottomLeftView = UIView()
47-
private let bottomCenterView = UIView()
48-
private let bottomRightView = UIView()
46+
fileprivate let bottomLeftView = UIView()
47+
fileprivate let bottomCenterView = UIView()
48+
fileprivate let bottomRightView = UIView()
4949

50-
private let rightTopView = UIView()
51-
private let rightCenterView = UIView()
52-
private let rightBottomView = UIView()
50+
fileprivate let rightTopView = UIView()
51+
fileprivate let rightCenterView = UIView()
52+
fileprivate let rightBottomView = UIView()
53+
54+
fileprivate let relativeView = UIView()
55+
fileprivate let childRelativeView = UIView()
5356

5457
init() {
5558
super.init(frame: .zero)

PinLayout.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
2419623A1E7F582C00A0466C /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 241962381E7F582C00A0466C /* Quick.framework */; };
1212
2419623C1E7F592800A0466C /* Nimble.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 241962371E7F582C00A0466C /* Nimble.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
1313
2419623D1E7F592800A0466C /* Quick.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 241962381E7F582C00A0466C /* Quick.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
14+
242E8DC31EED5AB2005935FB /* RelativePositionMultipleViewsSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 242E8DC11EED5982005935FB /* RelativePositionMultipleViewsSpec.swift */; };
1415
244C6E151E776A0C0074FC74 /* MarginsSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 244C6E141E776A0C0074FC74 /* MarginsSpec.swift */; };
1516
245302071ED05FD000E13F29 /* AccurencyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 245302061ED05FD000E13F29 /* AccurencyTests.swift */; };
1617
2469C4FC1E74855D00073BEE /* PinEdgeCoordinateSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2469C4FB1E74855D00073BEE /* PinEdgeCoordinateSpec.swift */; };
@@ -57,6 +58,7 @@
5758
/* Begin PBXFileReference section */
5859
241962371E7F582C00A0466C /* Nimble.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nimble.framework; path = Carthage/Build/iOS/Nimble.framework; sourceTree = "<group>"; };
5960
241962381E7F582C00A0466C /* Quick.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quick.framework; path = Carthage/Build/iOS/Quick.framework; sourceTree = "<group>"; };
61+
242E8DC11EED5982005935FB /* RelativePositionMultipleViewsSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RelativePositionMultipleViewsSpec.swift; sourceTree = "<group>"; };
6062
244C6E141E776A0C0074FC74 /* MarginsSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MarginsSpec.swift; sourceTree = "<group>"; };
6163
245302061ED05FD000E13F29 /* AccurencyTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AccurencyTests.swift; sourceTree = "<group>"; };
6264
2469C4FB1E74855D00073BEE /* PinEdgeCoordinateSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PinEdgeCoordinateSpec.swift; sourceTree = "<group>"; };
@@ -151,6 +153,7 @@
151153
246D36471E6C46F50050F202 /* PinPointCoordinatesSpec.swift */,
152154
2469C5031E75DB7600073BEE /* RectNimbleMatcher.swift */,
153155
2482908B1E78CFFC00667D08 /* RelativePositionSpec.swift */,
156+
242E8DC11EED5982005935FB /* RelativePositionMultipleViewsSpec.swift */,
154157
);
155158
path = Tests;
156159
sourceTree = "<group>";
@@ -321,6 +324,7 @@
321324
files = (
322325
2469C5001E75D74000073BEE /* AdjustSizeSpec.swift in Sources */,
323326
2482908C1E78CFFC00667D08 /* RelativePositionSpec.swift in Sources */,
327+
242E8DC31EED5AB2005935FB /* RelativePositionMultipleViewsSpec.swift in Sources */,
324328
2469C5041E75DB7600073BEE /* RectNimbleMatcher.swift in Sources */,
325329
245302071ED05FD000E13F29 /* AccurencyTests.swift in Sources */,
326330
2469C4FC1E74855D00073BEE /* PinEdgeCoordinateSpec.swift in Sources */,

Sources/PinLayout.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,14 @@ public protocol PinLayout {
182182
//
183183
// Layout using relative positioning
184184
//
185-
@discardableResult func above(of relativeView: UIView) -> PinLayout
186-
@discardableResult func above(of relativeView: UIView, aligned: HorizontalAlignment) -> PinLayout
187-
@discardableResult func below(of relativeView: UIView) -> PinLayout
188-
@discardableResult func below(of relativeView: UIView, aligned: HorizontalAlignment) -> PinLayout
189-
@discardableResult func left(of relativeView: UIView) -> PinLayout
190-
@discardableResult func left(of relativeView: UIView, aligned: VerticalAlignment) -> PinLayout
191-
@discardableResult func right(of relativeView: UIView) -> PinLayout
192-
@discardableResult func right(of relativeView: UIView, aligned: VerticalAlignment) -> PinLayout
185+
@discardableResult func above(of relativeViews: UIView...) -> PinLayout
186+
@discardableResult func above(of relativeViews: UIView..., aligned: HorizontalAlignment) -> PinLayout
187+
@discardableResult func below(of relativeViews: UIView...) -> PinLayout
188+
@discardableResult func below(of relativeViews: UIView..., aligned: HorizontalAlignment) -> PinLayout
189+
@discardableResult func left(of relativeViews: UIView...) -> PinLayout
190+
@discardableResult func left(of relativeViews: UIView..., aligned: VerticalAlignment) -> PinLayout
191+
@discardableResult func right(of relativeViews: UIView...) -> PinLayout
192+
@discardableResult func right(of relativeViews: UIView..., aligned: VerticalAlignment) -> PinLayout
193193

194194
//
195195
// Width, height and size

0 commit comments

Comments
 (0)