Created
August 15, 2020 14:59
-
-
Save sukidhar/e7f92ca0db783c17c85946c321241ef3 to your computer and use it in GitHub Desktop.
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 View { | |
func cornerRadius(_ radius: CGFloat, corners: UIRectCorner) -> some View { | |
clipShape( RoundedCorner(radius: radius, corners: corners) ) | |
} | |
} | |
struct RoundedCorner: Shape { | |
var radius: CGFloat = .infinity | |
var corners: UIRectCorner = .allCorners | |
func path(in rect: CGRect) -> Path { | |
let path = UIBezierPath(roundedRect: rect, byRoundingCorners: corners, cornerRadii: CGSize(width: radius, height: radius)) | |
return Path(path.cgPath) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment