Created
November 8, 2018 14:16
-
-
Save DanielCardonaRojas/25b666e9856b6f77288edfa8cc2f1b7b to your computer and use it in GitHub Desktop.
Random Swift Extensions (TODO: Order as this gist grows)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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