Easily embed Unsplash photos in UIImageView. Using Unsplash Source API.
UnsplashImageView allows to display Unsplash photos in UIImageView and make transitions between images. It uses Unsplash Source API.
UnsplashImageView is available through CocoaPods. To install
it, simply add the following line to your Podfile:
pod 'UnsplashImageView'
import UnsplashImageView
With default configuration
UnsplashConfig.default.query = .random(featured: true) // Query to Unsplash. Default is `.random(featured: false)`.
UnsplashConfig.default.size = CGSize(width: 600, height: 600) // Specifies the size of images. Default is `nil`.
UnsplashConfig.default.terms = ["fruit", "vegan"] // Search terms. Default is `nil`.
UnsplashConfig.default.mode = .gallery(interval: 10.0, transition: .fade(0.5)) // Image loading mode. Default is `single`.
UnsplashConfig.default.fixed = .none
Start getting images
let imageView = UIImageView()
// ...
imageView.unsplash.start()
Stop getting images (if gallery
mode enabled)
imageView.unsplash.stop()
With custom configuration
var config = UnsplashConfig()
config.query = .randomFromUser(username: "ari_spada")
config.mode = .single(transition: .none)
config.fixed = .daily
imageView.unsplash.start(with: config)
single
. Get a single image.gallery
. Get a new image every x seconds.photo(id: String)
. Get a specific photo by id.random(featured: Bool)
. Get a random photo from Unsplash. If featured
is true
, it gets it from curated collections.randomFromUser(username: String)
. Get a random photo from a specific user.randomFromUserLikes(username: String)
. Get a random photo from a user’s likes.randomFromCollection(id: String)
. Get a random photo from a specific collection.none
. Always request a new photo. Default value.daily
. Returns the same photo during a day for the same query.weekly
. Returns the same photo during a week for the same query.adboco@telefonica.net, Adrián Bouza Correa
UnsplashImageView is available under the MIT license. See the LICENSE file for more info.