Displaying multiple images like Twitter.
pod 'MultipleImageView'
github "nnsnodnb/MultipleImageView"
// swift-tools-version:5.0
import PackageDescription
let package = Package(
name: "SampleApp",
dependencies: [
.package(name: "MultipleImageView",
url: "https://github.com/nnsnodnb/MultipleImageView.git",
from: "0.2.0")
],
.targets: [
.target(name: "SampleApp,
dependencies: ["MultipleImageView"])
]
)
import MultipleImageView
final class SomeView: UIView, MultipleImageViewDelegate {
func configure() {
let imageView = MultipleImageView(frame: .zero)
addSubview(imageView)
// Autolayout
imageView.sources = [
.uiimage(anyImage),
.url(anyURL),
.custom { imageView in
// something fetch image
imageView.image = image
}
]
imageView.delegate = self
}
// MARK: - MultipleImageViewDelegate
func multipleImageViewShouldGetImage(_ imageView: UIImageView, sourceForURL url: URL, index: Int) {
// Your project's image fetch & cache algorithm.
}
func multipleImageViewDidSelect(_ imageView: UIImageView, index: Int) {
}
}
And please see Example project.
MultipleImageView is released under the MIT license. See LICENSE for details.