rotation3DEffect(_:axis:anchor:)
Rotates the view’s content by an angle about an axis that you specify as a tuple of elements.
Declaration
nonisolated func rotation3DEffect(_ angle: Angle, axis: (x: CGFloat, y: CGFloat, z: CGFloat), anchor: UnitPoint3D = .center) -> some View
Parameters
- angle:
The angle by which to rotate the view’s content.
- axis:
The axis of rotation, specified as a tuple with named elements for each of the three spatial dimensions.
- anchor:
The unit point within the view about which to perform the rotation. The default value is Center.
Return Value
A view with rotated content.
Discussion
This modifier rotates the view’s content without changing the view’s frame. The following code displays a 3D model with a rotation of 45° about the y-axis using the default anchor point at the center of the view:
Model3D(named: "robot")
.rotation3DEffect(.degrees(45), axis: (x: 0, y: 1, z: 0))let rotation = Rotation3D(
.init(degrees: 45), axis: RotationAxis3D(x: 0, y: 1, z: 0))
Model3D(named: "robot")
.rotation3DEffect(rotation)See Also
Scaling, rotating, or transforming a view
scaledToFill()scaledToFit()scaleEffect(_:anchor:)scaleEffect(_:anchor:)scaleEffect(x:y:anchor:)scaleEffect(x:y:z:anchor:)aspectRatio(_:contentMode:)rotationEffect(_:anchor:)rotation3DEffect(_:axis:anchor:anchorZ:perspective:)perspectiveRotationEffect(_:axis:anchor:anchorZ:perspective:)rotation3DEffect(_:anchor:)transformEffect(_:)transform3DEffect(_:)projectionEffect(_:)ProjectionTransform