Skip to content

Commit dc0d258

Browse files
leading|trailingAnchors
1 parent 34c683b commit dc0d258

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

DeclarativeLayoutKit.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |spec|
22

33
spec.name = "DeclarativeLayoutKit"
4-
spec.version = "3.0.2"
4+
spec.version = "3.0.3"
55
spec.summary = "UIKit declarative layout like SwiftUI."
66
spec.homepage = "https://github.com/Ernest0-Production/DeclarativeLayoutKit"
77
spec.license = { :type => "MIT", :file => "LICENSE.md" }

Sources/DeclarativeLayoutKit/AutoLayout/AnchorsFactory.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,17 @@ public extension AutoLayoutItemConvertible {
6464
})
6565
}
6666

67+
func leadingAnchor(_ anchor: HorizontalRelativeAutoLayoutAnchorConvertible) -> AutoLayoutItem {
68+
asAutoLayoutItem().layout({ view in
69+
makeRelativeConstraint(
70+
view: view,
71+
anchorProvider: { $0.leadingAnchor },
72+
second: anchor.asHorizontalRelativeAutoLayoutAnchor(),
73+
invertConstant: false
74+
)
75+
})
76+
}
77+
6778
func rightAnchor(_ anchor: HorizontalRelativeAutoLayoutAnchorConvertible) -> AutoLayoutItem {
6879
asAutoLayoutItem().layout({ view in
6980
makeRelativeConstraint(
@@ -75,6 +86,17 @@ public extension AutoLayoutItemConvertible {
7586
})
7687
}
7788

89+
func trailingAnchor(_ anchor: HorizontalRelativeAutoLayoutAnchorConvertible) -> AutoLayoutItem {
90+
asAutoLayoutItem().layout({ view in
91+
makeRelativeConstraint(
92+
view: view,
93+
anchorProvider: { $0.trailingAnchor },
94+
second: anchor.asHorizontalRelativeAutoLayoutAnchor(),
95+
invertConstant: false
96+
)
97+
})
98+
}
99+
78100
func centerXAnchor(_ anchor: HorizontalRelativeAutoLayoutAnchorConvertible = 0) -> AutoLayoutItem {
79101
asAutoLayoutItem().layout({ view in
80102
makeRelativeConstraint(

0 commit comments

Comments
 (0)