Skip to content

Instantly share code, notes, and snippets.

@garethng
Created August 12, 2022 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 garethng/e568284536ba7c2cfb63942d809f2fe1 to your computer and use it in GitHub Desktop.
Save garethng/e568284536ba7c2cfb63942d809f2fe1 to your computer and use it in GitHub Desktop.
set roundCorner for UIView (select the corners)
extension UIView {
func roundCorners(corners: UIRectCorner, radius: CGFloat) {
let path = UIBezierPath(roundedRect: bounds, byRoundingCorners: corners, cornerRadii: CGSize(width: radius, height: radius))
let mask = CAShapeLayer()
mask.path = path.cgPath
layer.mask = mask
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment