Round corners with RoundedRect when rounding all corners (#1504)

This commit is contained in:
Sam 2025-04-19 12:19:18 -07:00 committed by GitHub
parent 9576470683
commit 48cf179691
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 1 deletions

View File

@ -161,9 +161,14 @@ extension View {
shadow(radius: 4, y: 2)
}
@ViewBuilder
func cornerRadius(_ radius: CGFloat, corners: UIRectCorner) -> some View {
if corners == .allCorners {
clipShape(RoundedRectangle(cornerRadius: radius))
} else {
clipShape(RoundedCorner(radius: radius, corners: corners))
}
}
/// Apply a corner radius as a ratio of a view's side
func cornerRadius(ratio: CGFloat, of side: KeyPath<CGSize, CGFloat>, corners: UIRectCorner = .allCorners) -> some View {