I copied this period of code to make a clipped shape of rounded corner. But the "rect" variable make me puzzled. It isn't an input variable.How can I use this struct without passing a value or initialize it.
import SwiftUI
struct RoundedShape:Shape{
var corners:UIRectCorner
func path(in rect:CGRect) -> Path {
let path=UIBezierPath(roundedRect: rect, byRoundingCorners: corners, cornerRadii: CGSize(width: 80, height: 80))
return Path(path.cgPath)
}
}
⬆️ This is what I got from Internet
Rectangle()
.clipShape( RoundedShape(corners: [.bottomRight]))
}
And I use this struct here and got this
Nothing wrong with the result,I just don't understand why this works without any passing or initializing to the "rect".
If you can help me, I appreciate it a lot.