Skip to content

Instantly share code, notes, and snippets.

@vkostechko
Last active February 21, 2018 08:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vkostechko/11df0378617de3060b580660ba2546c5 to your computer and use it in GitHub Desktop.
Save vkostechko/11df0378617de3060b580660ba2546c5 to your computer and use it in GitHub Desktop.
extension UIView {
func roundCorners(_ corners: UIRectCorner, radius: CGFloat) {
let path = UIBezierPath(roundedRect: self.bounds, byRoundingCorners: corners, cornerRadii: CGSize(width: radius, height: radius))
let mask = CAShapeLayer()
mask.path = path.cgPath
self.layer.mask = mask
}
}
usage:
view.roundCorners([.topLeft, .bottomRight], radius: 10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment