iOS性能优化之图片最佳实践( 三 )


let serialQueue = DispatchQueue(label: "Decode queue") func collectionView(_ collectionView: UICollectionView,prefetchItemsAt indexPaths: [IndexPath]) { // Asynchronously decode and downsample every image we are about to show for indexPath in indexPaths {serialQueue.async {let downsampledImage = downsample(images[indexPath.row])DispatchQueue.main.async { self.update(at: indexPath, with: downsampledImage)} } }



推荐阅读