Skip to content

Instantly share code, notes, and snippets.

@novinfard
Created June 28, 2021 21:50
Show Gist options
  • Save novinfard/d14fd9247f6b8a00ef9599fc42d61105 to your computer and use it in GitHub Desktop.
Save novinfard/d14fd9247f6b8a00ef9599fc42d61105 to your computer and use it in GitHub Desktop.
[Force RTL in SwiftUI]
final class SceneDelegate: UIResponder, UIWindowSceneDelegate {
func scene(_ scene: UIScene,
willConnectTo session: UISceneSession,
options connectionOptions: UIScene.ConnectionOptions) {
let contentView = ContentView().environment(\.layoutDirection, .rightToLeft)
if let windowScene = scene as? UIWindowScene {
let window = UIWindow(windowScene: windowScene)
window.rootViewController = UIHostingController(rootView: contentView)
self.window = window
window.makeKeyAndVisible()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment