Last active
May 22, 2023 11:23
-
-
Save comcxx11/169ff7c15528d91b4c1b14d48dbe726d to your computer and use it in GitHub Desktop.
20230522
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
box.layer.cornerRadius = 20; | |
box.layer.masksToBounds = true; |
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 | |
} | |
} |
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
box.roundCorners(corners: [.topLeft, .topRight], radius: 20.0) |
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
box.roundCorners(corners: [.topLeft, .bottomRight], radius: 20.0) |
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
box.roundCorners(corners: [.bottomLeft, .bottomRight], radius: 20.0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment