Ger*_*eon 6 uisegmentedcontrol swiftui
在一个小示例 SwiftUI 应用程序中,我有一个设置视图,显示了几个选项选择,实现为分段控件。当出现或解除警报时,这些分段控件中的文本会明显移动。有没有办法摆脱这个故障?
将此粘贴到 Playground 中以重现:
import SwiftUI
import PlaygroundSupport
struct FlickeringSegmentsView: View {
@State var option = 0
@State var alerting = false
var body: some View {
VStack(alignment: .center, spacing: 120) {
Picker("options", selection: $option) {
Text("Option A").tag(0)
Text("Option B").tag(1)
}
.pickerStyle(SegmentedPickerStyle())
.padding(16)
Button(action: { self.alerting.toggle() },
label: { Text("Show Alert") }
)
.alert(isPresented: $alerting) {
Alert(title: Text("Alert"))
}
}
}
}
PlaygroundPage.current.setLiveView(FlickeringSegmentsView())
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
575 次 |
| 最近记录: |