Search code examples
iosswiftuilocalizationarabicright-to-left

SwiftUI - disable certain views from flipping for right to left languages


When our app runs in a right to left language like Hebrew or Arabic, the SwiftUI views automatically flip the positions of our views to be right to left. Some of this is very helpful, but certain views should not be flipped.

We tried .flipsForRightToLeftLayoutDirection(false) on the views but this didn't prevent them from being positioned differently when running with the scheme set to Hebrew or Arabic.

Would appreciate any help. Thank you!


Solution

  • You can force the layout direction using .environment:

    .environment(\.layoutDirection, .leftToRight)