As you can see in the attached image, the picker options are not aligned automatically to the right-hand side for RTL languages, and also flipped.
The picker is nothing fancy either, the standard way.
struct ContentView: View {
@State private var selectedDay: String = "יום שבת"
private let days: [String] = ["יום שבת", "יוֹם רִאשׁוֹן", "יוֹם שֵׁנִי"]
var body: some View {
Picker(selection: $selectedDay) {
ForEach(days, id: \.self) { day in
Text(day).tag(day)
}
} label: {
Text("")
}
}
}
I have changed the development localization to Hebrew so RTL alignments are automatically done.
I have tried to force the alignment with
.environment(\.layoutDirection, .rightToLeft)
but nothing has worked.
I came across this question seems a year later since I asked it XD. I have managed to get it to work in RTL :
If you only do this step, the RTL layout will appear correctly in the simulator but not on a real device (unless the device's language is RTL)
This will force the app's preferred language to always remain your RTL language.
@main
struct AppName: App {
init() {
UserDefaults.standard.set(["ar"], forKey: "AppleLanguages")
}
var body: some Scene {
WindowGroup {
ContentView()
}
}
}