在下面的简单示例中,您会发现第一次点击时Toggle Loading
the ProgressView
按应有的方式显示,但第二次(第三次点击)却没有显示。
看来是周围的List造成的。
有什么想法以及如何使其发挥作用吗?
struct ContentView: View {
@State private var isLoading = false
var body: some View {
List {
if isLoading {
HStack(alignment: .center, spacing: 10) {
ProgressView()
Text("Loading")
}
} else {
Text("Not Loading")
}
Button("Toggle Loading") {
isLoading.toggle()
}
}
}
}
struct ContentView: View {
@State private var isLoading = false
var body: some View {
List {
HStack(alignment: .center, spacing: 10) {
if isLoading {
ProgressView()
}
Text(isLoading ? "Loading" : "Not Loading")
}
Button("Toggle Loading") {
isLoading.toggle()
}
}
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)