02-ContentView-4.swift 640 B

12345678910111213141516171819202122
  1. import SwiftUI
  2. import Kingfisher
  3. struct ContentView: View {
  4. func url(at index: Int) -> URL? {
  5. let urlPrefix = "https://raw.githubusercontent.com/onevcat/Kingfisher-TestImages/master/DemoAppImage/Loading/kingfisher"
  6. return URL(string: "\(urlPrefix)-\(index + 1).jpg")
  7. }
  8. var body: some View {
  9. List {
  10. ForEach(0 ..< 10) { i in
  11. HStack {
  12. KFImage(url(at: i))
  13. .resizable()
  14. .frame(width: 64, height: 64)
  15. Text("Index \(i)")
  16. }
  17. }
  18. }.listStyle(.plain)
  19. }
  20. }