SKPhotoBrowser-Kingfisher
使用方法
示例项目
要运行示例项目,请克隆仓库,然后首先从 Example 目录运行 pod install
。它包括示例代码和单元测试。
就像使用 SKPhoto
一样,我们使用 KFPhoto
。因为 SKPhotoBrowser 使用 var photos: [SKPhotoProtocol]
,我们可以轻松切换到 KFPhoto
。当然,您也可以使用您自己的自定义照片,只要它确认实现了 SKPhotoProtocol
。
// 1. default use SKPhoto
var images = [SKPhoto]()
for url in urls {
let photo = SKPhoto.photoWithImageURL(url)
photo.shouldCachePhotoURLImage = true // you can use image cache by true(NSCache)
images.append(photo)
}
// 2. use KFPhoto by SKPhotoBrowser-Kingfisher
var images = [KFPhoto]()
for (index, url) in urls.enumerated() {
let holder = ImageCache.default.retrieveImageInDiskCache(forKey: middlePics[index])
let photo = KFPhoto(url: url, holder: holder)
images.append(photo)
}
安装
CocoaPods
SKPhotoBrowser-Kingfisher 可通过 CocoaPods 获取。要安装它,只需将以下行添加到您的 Podfile 中
pod "SKPhotoBrowser-Kingfisher"
作者
Ge Will
邮箱: [email protected]
主页: https://gewill.org/
Twitter: @gewill_org
许可协议
SKPhotoBrowser-Kingfisher 在 MIT 许可协议下可用。有关更多信息,请参阅 LICENSE 文件。