Skip to content

Commit

Permalink
Add offset modifier (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
muukii committed Aug 9, 2023
1 parent 50785e2 commit 5ebbc98
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Sources/LayoutSpecBuilders/Modifiers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,18 @@ fileprivate func combineInsets(_ lhs: UIEdgeInsets, rhs: UIEdgeInsets) -> UIEdge
return base
}

// MARK: - Offset
extension _ASLayoutElementType {

public func offset(width: CGFloat = 0, height: CGFloat = 0) -> InsetLayout<Self> {
return offset(.init(width: width, height: height))
}

public func offset(_ size: CGSize) -> InsetLayout<Self> {
return padding(UIEdgeInsets(top: size.height, left: size.width, bottom: -size.height, right: -size.width))
}
}

// MARK: - Padding
extension _ASLayoutElementType {

Expand Down

0 comments on commit 5ebbc98

Please sign in to comment.