Skip to content

Instantly share code, notes, and snippets.

@dotWasim
Created January 4, 2021 10:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dotWasim/2462e32a29ec53b8ba4798f82cc206ee to your computer and use it in GitHub Desktop.
Save dotWasim/2462e32a29ec53b8ba4798f82cc206ee to your computer and use it in GitHub Desktop.
Fix right-to-left ScrollView in SwiftUI
import SwiftUI
struct TestView: View {
var data = ["Test 1", "Test 2"]
var body: some View {
ScrollView(.horizontal) {
HStack{
ForEach(data, id: \.self) { name in
Text(name)
}
}
.environment(\.layoutDirection, .rightToLeft)
.rotation3DEffect(Angle(degrees: 180), axis: (x: CGFloat(0), y: CGFloat(10), z: CGFloat(0)))
}
.flipsForRightToLeftLayoutDirection(true)
}
}
struct TestView_Previews: PreviewProvider {
static var previews: some View {
TestView()
.environment(\.layoutDirection, .rightToLeft)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment