Created
January 4, 2021 10:06
-
-
Save dotWasim/2462e32a29ec53b8ba4798f82cc206ee to your computer and use it in GitHub Desktop.
Fix right-to-left ScrollView in SwiftUI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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