Use any one of the .rotationEffect()
methods to rotate any View
clockwise, including Button
and Text
.
For example, this rotates Text
about its origin (the center of its frame):
Text("Turtle Rock")
.rotationEffect(Angle(degrees: 90)))
Use the overloaded method with an anchor argument to rotate around a different point.
For example, this rotates Text
about the bottom left point of its frame:
Text("Turtle Rock")
.rotationEffect(Angle(degrees: 90), anchor: .bottomLeading)
You can also use radians for rotation:
Text("Turtle Rock")
.rotationEffect(radians: Double.pi / 2)