はじめに
refreshable
を使ったことがなかったので簡単なサンプルを作成してみました
サンプルアプリ
実装
import SwiftUI
struct ContentView: View {
@State private var items: [String] = ["サンプルセル", "サンプルセル"]
var body: some View {
List {
ForEach(items, id: \.self) { item in
Text(item)
}
}
.refreshable {
try? await Task.sleep(nanoseconds: 3 * NSEC_PER_SEC)
items.append("サンプルセル")
}
}
}
おわり
Twitter的なアプリを簡単に作れますね