Updated for Xcode 12.5
Any SwiftUI view can have its corners rounded using the
cornerRadius() modifier. This takes a simple value in points that controls how pronounced the rounding should be.
So, you can create a text view with 25-point rounded corners like this:
Text("Round Me") .padding() .background(Color.red) .cornerRadius(25)
You can automatically round the shortest edge fully by using the
clipShape() modifier with a
Capsule, like this:
Text("Round Me") .padding() .background(Color.red) .clipShape(Capsule())
SPONSORED Emerge helps iOS devs write better, smaller apps by profiling binary size on each pull request and surfacing insights and suggestions. Companies using Emerge have reduced the size of their apps by up to 50% in just the first day. Built by a team with years of experience reducing app size at Airbnb.
Link copied to your pasteboard.