How To Rotate View In SwiftUI

SwiftUI has two modifiers to rotate the view, one it rotationEffect and the second is rotation3DEffect.

The rotationEffect changes Z-axis of the view. It accepts Angle in the constructor which can be used with degrees or with radians.

Text(“Smash”)
    .rotationEffect(.degrees(180.0))

Or with radians.

Text(“Swift”)
    .rotationEffect(.radians(.pi))

If you need to changes other axes than Z use the 3D effect.

Text(“SmashSwift”)
    .rotation3DEffect(.degrees(180.0), axis: (x: 0, y: 0, z: 1))

All three examples rotate views in the same, the text is upside down.