Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MojtabaHs/81395bb2be673698e6531b7e56ba5c61 to your computer and use it in GitHub Desktop.
Save MojtabaHs/81395bb2be673698e6531b7e56ba5c61 to your computer and use it in GitHub Desktop.
struct ContentView: View {
@State var topLeading: CGFloat = 0
@State var topTrailing: CGFloat = 50
@State var bottomLeading: CGFloat = 50
@State var bottomTrailing: CGFloat = 0
var body: some View {
VStack {
HStack(spacing: 32) {
Slider(value: $topLeading, in: 0...50)
Slider(value: $topTrailing, in: 0...50)
}
Text("Round me")
.frame (width: 200, height: 100)
.background(.red)
.clipShape(
.rect(
topLeadingRadius: topLeading,
bottomLeadingRadius: bottomLeading,
bottomTrailingRadius: bottomTrailing,
topTrailingRadius: topTrailing,
style: .continuous
)
)
HStack(spacing: 32) {
Slider(value: $bottomLeading, in: 0...50)
Slider(value: $bottomTrailing, in: 0...50)
}
}.padding()
}
}
@MojtabaHs
Copy link
Author

MojtabaHs commented Jun 21, 2023

⚠️ Important Note:

Although it works from iOS 16, .rect needs Xcode 15 to be available.

💡 You can use this method until the GM release of the Xcode 15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment