Skip to content

Instantly share code, notes, and snippets.

@DanielCardonaRojas
Created November 8, 2018 14:16
Show Gist options
  • Save DanielCardonaRojas/25b666e9856b6f77288edfa8cc2f1b7b to your computer and use it in GitHub Desktop.
Save DanielCardonaRojas/25b666e9856b6f77288edfa8cc2f1b7b to your computer and use it in GitHub Desktop.
Random Swift Extensions (TODO: Order as this gist grows)
extension UIEdgeInsets {
static func with(_ constant: CGFloat) -> UIEdgeInsets {
return UIEdgeInsets(top: constant, left: constant, bottom: constant, right: constant)
}
}
extension Comparable {
func clamp(min: Self, max: Self) -> Self {
if self < min {
return min
} else if self > max {
return max
} else {
return self
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment