Hes*_*mal 5 swiftui swiftui-form ios14 swiftui-navigationview
目前,我已经picker
包含在 aSection
中Form
,我想要达到的目标是将所选值picker
与 iOS 13 和 14 中的前导对齐,我已经尝试了许多解决方案,例如labelsHidden()
但没有结果,请找到在 iOS 14 上生成以下屏幕截图的代码示例,任何帮助将不胜感激
struct ContentView: View {
@State private var selectedStrength = "Mild"
let strengths = ["Mild", "Medium", "Mature"]
var body: some View {
NavigationView {
Form {
Section {
Picker("", selection: $selectedStrength) {
ForEach(strengths, id: \.self) {
Text($0)
}
}
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
在 a 中使用 theText()
和 aSpacer()
HStack()
struct ContentView: View {
@State private var selectedStrength = "Mild"
let strengths = ["Mild", "Medium", "Mature"]
var body: some View {
NavigationView {
Form {
Section {
Picker("", selection: $selectedStrength) {
ForEach(strengths, id: \.self) { t in
HStack {
Text(t)
Spacer()
}
}
}
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2241 次 |
最近记录: |