rotation3DEffect
Renders a view's content as if it's rotated in three dimensions around the specified axis.
Declaration
compose().rotation3DEffect(
angle: SwiftUI.Angle,
options: {
axis: [ x: number, y: number, z: number ];
anchor?: SwiftUI.UnitPoint;
anchorZ?: number;
perspective?: number;
}
)nonisolated func rotation3DEffect(
_ angle: Angle,
axis: (x: CGFloat, y: CGFloat, z: CGFloat),
anchor: UnitPoint = .center,
anchorZ: CGFloat = 0,
perspective: CGFloat = 1
) -> some ViewParameters
angle*SwiftUI.AngleThe angle by which to rotate the view's content.
options.axis*[ x: number, y: number, z: number ]The axis of rotation, specified as a tuple with named elements for each of the three spatial dimensions.
options.anchorSwiftUI.UnitPointA two dimensional unit point within the view about which to perform the rotation. The default value is
UnitPoint.center.options.anchorZnumberThe location on the z-axis around which to rotate the content. The default is
0.options.perspectivenumberThe relative vanishing point for the rotation. The default is
1.
Return value
A view with rotated content.
Discussion
Use this method to create the effect of rotating a view in three
dimensions around a specified axis of rotation. The modifier projects
the rotated content onto the original view's plane. Use the
perspective value to control the renderer's vanishing point. The
following example creates the appearance of rotating text 45˚ about
the y-axis:
Text("Rotation by passing an angle in degrees")
.rotation3DEffect(
.degrees(45),
axis: (x: 0.0, y: 1.0, z: 0.0),
anchor: .center,
anchorZ: 0,
perspective: 1)
.border(Color.gray)See also
More in Visual effects.
- allowedDynamicRangeReturns a new view configured with the specified allowed dynamic range.
- backgroundExtensionEffectAdds the background extension effect to the view. The view will be duplicated into mirrored copies which will be placed around the view on any edge with available safe area. Additionally, a blur effect will be applied on top to blur out the copies.
- blurApplies a Gaussian blur to this view.
- brightnessBrightens this view by the specified amount.
- clippedClips this view to its bounding rectangular frame.
- colorEffectReturns a new view that applies shader to self as a filter effect on the color of each pixel.
- colorInvertInverts the colors in this view.
- colorMultiplyAdds a color multiplication effect to this view.
- compositingGroupWraps this view in a compositing group.
- contrastSets the contrast and separation between similar colors in this view.
- distortionEffectReturns a new view that applies shader to self as a geometric distortion effect on the location of each pixel.
- drawingGroupComposites this view's contents into an offscreen image before final display.