Saj*_*jad 4 ios swift swiftui xcode11
我们如何在 swiftUI 的 Horizontal ScrollView 中设置从右到左的布局方向?
像这样:
ScrollView(showsHorizontalIndicator: false) {
HStack {
VStack {
Image("1")
Text("one")
}
VStack {
Image("2")
Text("two")
}
VStack {
Image("3")
Text("three")
}
}
}
Run Code Online (Sandbox Code Playgroud)
所以当模拟器运行时,我想Image("1")在右手边看到并向右滑动可以访问Image("3")
您可以view通过提供view以下修饰符从右到左制作任何您想要的东西:
.flipsForRightToLeftLayoutDirection(true)
.environment(\.layoutDirection, .rightToLeft)
Run Code Online (Sandbox Code Playgroud)
在你的情况下,它会是这样的:
ScrollView(showsHorizontalIndicator: false) {
HStack {
VStack {
Image("1")
Text("one")
}
VStack {
Image("2")
Text("two")
}
VStack {
Image("3")
Text("three")
}
}
}
.flipsForRightToLeftLayoutDirection(true)
.environment(\.layoutDirection, .rightToLeft)
Run Code Online (Sandbox Code Playgroud)
好运达达什 ;)
| 归档时间: |
|
| 查看次数: |
1388 次 |
| 最近记录: |