SwiftUI Pull to Refresh(适用于 iOS 13 和 iOS 14)包
可刷新
✳️ SwiftUI Pull to Refresh(适用于 iOS 13 和 iOS 14)包。
请参阅 SwiftUI Pull to Refresh(适用于 iOS 13 和 iOS 14)中的补充文章。使用此扩展,您可以将 iOS 15 可刷新修饰符向后移植到 iOS 13 和 iOS 14,并全面使用完全相同的代码。
SwiftUI_Pull_to_Refresh_iOS_13_iOS_14.mp4
struct ContentView: View {
...
var body: some View {
List {
...
}
.refreshable {
await viewModel.fetch()
}
}
}
Alternatively, you can opt into the closure-based API below to spare using async await API.
struct ContentView: View {
...
var body: some View {
List {
...
}
.onRefresh { refreshControl in
viewModel.fetch {
refreshControl.endRefreshing()
}
}
}
}
License
Licensed under the MIT License.