LayoutDirection
A direction in which SwiftUI can lay out content.
Declaration
type LayoutDirection = 'leftToRight' | 'rightToLeft';enum LayoutDirectionPass a literal, or build one with SwiftUI.LayoutDirection from import { SwiftUI } from 'swiftui-react-native'.
Type properties
'leftToRight'SwiftUI.LayoutDirection.leftToRightA left-to-right layout direction.
'rightToLeft'SwiftUI.LayoutDirection.rightToLeftA right-to-left layout direction.
Overview
SwiftUI supports both left-to-right and right-to-left directions
for laying out content to support different languages and locales.
The system sets the value based on the user's locale, but
you can also use the View.environment(_:_:) modifier
to override the direction for a view and its child views:
MyView()
.environment(\.layoutDirection, .rightToLeft)You can also read the EnvironmentValues.layoutDirection environment
value to find out which direction applies to a particular environment.
However, in many cases, you don't need to take any action based on this
value. SwiftUI horizontally flips the x position of each view within its
parent, so layout calculations automatically produce the desired effect
for both modes without any changes.
From Apple’s SwiftUI documentation. Code samples there are Swift.
See also
More in Layout.
- AlignmentAn alignment in both axes.
- ContainerBackgroundPlacementThe placement of a container background.
- ContainerValuesReadableKeys of SwiftUI ContainerValues JavaScript can read.
- ContainerValuesWritableKeys of SwiftUI ContainerValues JavaScript can write.
- ControlSizeThe size classes, like regular or small, that you can apply to controls within a view.
- DocumentLaunchGeometryProxyA proxy for access to the frame of the scene and its title view.
- DynamicTypeSizeA Dynamic Type size, which specifies how large scalable content should be.
- EdgeAn enumeration to indicate one edge of a rectangle.
- EdgeInsetsThe inset distances for the sides of a rectangle.
- EdgeInsetsChainEdgeInsets with chained calls: SwiftUI.EdgeInsets.inset(...).
- EdgeSetAn efficient set of edges.
- GeometryProxyA proxy for access to the size and coordinate space (for anchor resolution) of the container view.