Skip to content

Commit

Permalink
Add Edges().to(_:) - Enables to attach the edge of the view to anothe…
Browse files Browse the repository at this point in the history
…r view or LayoutGuide. #106
  • Loading branch information
muukii authored Jan 14, 2021
1 parent 4e22389 commit b79a2ea
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions EasyPeasy/PositionAttribute+UIKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -324,5 +324,29 @@ public class CenterWithinMargins: CompoundAttribute {
}

}

extension Edges {

@available(iOS 9.0, *)
public func to(_ layoutGuide: UILayoutGuide) -> Edges {
self.attributes = [
Top().to(layoutGuide, .top),
Left().to(layoutGuide, .left),
Right().to(layoutGuide, .right),
Bottom().to(layoutGuide, .bottom),
]
return self
}

public func to(_ view: UIView) -> Edges {
self.attributes = [
Top().to(view, .top),
Left().to(view, .left),
Right().to(view, .right),
Bottom().to(view, .bottom),
]
return self
}
}

#endif

0 comments on commit b79a2ea

Please sign in to comment.