Skip to content

Instantly share code, notes, and snippets.

@migueltg
Created September 21, 2017 10:21
Show Gist options
  • Save migueltg/a634063dd9be09355b0796d3bacf975b to your computer and use it in GitHub Desktop.
Save migueltg/a634063dd9be09355b0796d3bacf975b to your computer and use it in GitHub Desktop.
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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment