Created
August 12, 2022 08:48
-
-
Save garethng/e568284536ba7c2cfb63942d809f2fe1 to your computer and use it in GitHub Desktop.
set roundCorner for UIView (select the corners)
This file contains 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 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