01-ViewController-8.swift 1.1 KB

123456789101112131415161718192021222324
  1. extension ViewController: UITableViewDataSource {
  2. func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  3. 10
  4. }
  5. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  6. let cell = tableView.dequeueReusableCell(withIdentifier: "SampleCell", for: indexPath) as! SampleCell
  7. cell.sampleLabel.text = "Index \(indexPath.row)"
  8. let urlPrefix = "https://raw.githubusercontent.com/onevcat/Kingfisher-TestImages/master/DemoAppImage/Loading/kingfisher"
  9. let url = URL(string: "\(urlPrefix)-\(indexPath.row + 1).jpg")
  10. cell.sampleImageView.kf.indicatorType = .activity
  11. let roundCorner = RoundCornerImageProcessor(radius: .widthFraction(0.5), roundingCorners: [.topLeft, .bottomRight])
  12. let pngSerializer = FormatIndicatedCacheSerializer.png
  13. cell.sampleImageView.kf.setImage(
  14. with: url,
  15. options: [.processor(roundCorner), .cacheSerializer(pngSerializer)]
  16. )
  17. cell.sampleImageView.backgroundColor = .clear
  18. return cell
  19. }
  20. }