Skip to content

Commit

Permalink
Merge pull request #155 from edulpn/layoutAnchorOperators
Browse files Browse the repository at this point in the history
Create Int and CGFloat variants for SteviaLayoutAnchor operators
  • Loading branch information
s4cha authored Nov 19, 2020
2 parents e1e8dc4 + 77cc666 commit a32dc3c
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions Sources/Stevia/Stevia+LayoutAnchors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,54 @@ public func - (left: SteviaLayoutXAxisAnchor, right: Double) -> SteviaLayoutXAxi
return SteviaLayoutXAxisAnchor(anchor: left.anchor, constant: -right)
}

@available(iOS 9.0, *)
@discardableResult
public func + (left: SteviaLayoutYAxisAnchor, right: CGFloat) -> SteviaLayoutYAxisAnchor {
return SteviaLayoutYAxisAnchor(anchor: left.anchor, constant: Double(right))
}

@available(iOS 9.0, *)
@discardableResult
public func - (left: SteviaLayoutYAxisAnchor, right: CGFloat) -> SteviaLayoutYAxisAnchor {
return SteviaLayoutYAxisAnchor(anchor: left.anchor, constant: Double(-right))
}

@available(iOS 9.0, *)
@discardableResult
public func + (left: SteviaLayoutXAxisAnchor, right: CGFloat) -> SteviaLayoutXAxisAnchor {
return SteviaLayoutXAxisAnchor(anchor: left.anchor, constant: Double(right))
}

@available(iOS 9.0, *)
@discardableResult
public func - (left: SteviaLayoutXAxisAnchor, right: CGFloat) -> SteviaLayoutXAxisAnchor {
return SteviaLayoutXAxisAnchor(anchor: left.anchor, constant: Double(-right))
}

@available(iOS 9.0, *)
@discardableResult
public func + (left: SteviaLayoutYAxisAnchor, right: Int) -> SteviaLayoutYAxisAnchor {
return SteviaLayoutYAxisAnchor(anchor: left.anchor, constant: Double(right))
}

@available(iOS 9.0, *)
@discardableResult
public func - (left: SteviaLayoutYAxisAnchor, right: Int) -> SteviaLayoutYAxisAnchor {
return SteviaLayoutYAxisAnchor(anchor: left.anchor, constant: Double(-right))
}

@available(iOS 9.0, *)
@discardableResult
public func + (left: SteviaLayoutXAxisAnchor, right: Int) -> SteviaLayoutXAxisAnchor {
return SteviaLayoutXAxisAnchor(anchor: left.anchor, constant: Double(right))
}

@available(iOS 9.0, *)
@discardableResult
public func - (left: SteviaLayoutXAxisAnchor, right: Int) -> SteviaLayoutXAxisAnchor {
return SteviaLayoutXAxisAnchor(anchor: left.anchor, constant: Double(-right))
}

// UILayoutSupport

@available(iOS 9.0, *)
Expand Down

0 comments on commit a32dc3c

Please sign in to comment.