Enumeration¶
LayoutDirection¶
The different text directions used in different languages.¶
Declaration¶
enum LayoutDirection : Hashable, CaseIterable
Overview¶
Use this enumeration with the LayoutDirection environment property. See layoutDirection for more on accessing and changing this property.
There are two possible layout directions:
Examples of left-to-right layout directions are English and Russian. Examples of right-to-left layout directions are Arabic and Hebrew.
In the example below, the left to right arrow is printed since we're in the English locale.
struct ContentView: View {
@Environment(\.layoutDirection) var direction
var body: some View {
Text(direction == LayoutDirection.leftToRight ? "➡️" : "⬅️")
.font(.title)
}
}

Availability¶
iOS 13.0+
macOS 10.15+
tvOS 13.0+
watchOS 6.0+
Topics¶
Type Property¶
allCases A collection of all values of this type.
Type Method¶
==(a:b:) Returns a Boolean value indicating whether two values are equal.
Initializer¶
init(_:) Create a direction from its UITraitEnvironmentLayoutDirection equivalent.
Type Alias¶
AllCases A type that can represent a collection of all values of this type.
Instance Method¶
hash(into:) Hashes the essential components of this value by feeding them into the given hasher.
Case¶
leftToRight The text is read and written from left to right.
rightToLeft The text is read and written from right to left.
Instance Property¶
hashValue The hash value.