Isa*_*aak 9 swift swiftui swiftui-list
在下面的简单示例中,您会发现第一次点击时按Toggle Loading
应有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()
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
小智 3
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()
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3219 次 |
最近记录: |