Skip to content

Instantly share code, notes, and snippets.

@tikipatel
Created April 10, 2020 16:28
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 tikipatel/9c44a768562437e2e7e40630b57d7600 to your computer and use it in GitHub Desktop.
Save tikipatel/9c44a768562437e2e7e40630b57d7600 to your computer and use it in GitHub Desktop.
Defines a shape that is rounded with given corners and radius.
import SwiftUI
struct RoundedCorner: Shape {
var radius: CGFloat
var corners: UIRectCorner
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