This project is only for SwiftUI
Pull-to-refresh functionality for List and ScrollView controls
Encapsulated UITableView, UIScrollView, UICollectionView can also be used
- iOS 13.0
- macOS 10.15
- tvOS 13.0
- watchOS 6.0
classViewModel:ObservableObject{@PublishedvarisRefresh:Bool=false}letarray=["text1","text2","text3"]@StateObjectprivatevarvm=ViewModel()varbody:someView{List{ForEach(0..<array.count){ index inlettext=array[index]HStack{Text(text)}}}.pullToRefresh($vm.isRefresh){
// refresh done
DispatchQueue.main.asyncAfter(deadline:.now()+5.0){
vm.isRefresh =false}}}You can add RefreshableScrollView to an Xcode project by adding it as a package dependency.
- From the File menu, select Swift Packages › Add Package Dependency…
- Enter https://github.com/HumorousGhost/RefreshableScrollView into the package repository URL text field
- Link RefreshableScrollView to your application target