项目作者: adboco

项目描述 :
Easily embed Unsplash photos in UIImageView. Using Unsplash Source API.
高级语言: Swift
项目地址: git://github.com/adboco/UnsplashImageView.git
创建时间: 2018-05-17T12:38:50Z
项目社区:https://github.com/adboco/UnsplashImageView

开源协议:MIT License

下载


UnsplashImageView

Version
License
Platform
Swift Version
FOSSA Status

UnsplashImageView allows to display Unsplash photos in UIImageView and make transitions between images. It uses Unsplash Source API.



Requirements

  • Xcode 9.0+
  • iOS 8.0+

Installation

UnsplashImageView is available through CocoaPods. To install
it, simply add the following line to your Podfile:

  1. pod 'UnsplashImageView'

Usage

  1. import UnsplashImageView

With default configuration

  1. UnsplashConfig.default.query = .random(featured: true) // Query to Unsplash. Default is `.random(featured: false)`.
  2. UnsplashConfig.default.size = CGSize(width: 600, height: 600) // Specifies the size of images. Default is `nil`.
  3. UnsplashConfig.default.terms = ["fruit", "vegan"] // Search terms. Default is `nil`.
  4. UnsplashConfig.default.mode = .gallery(interval: 10.0, transition: .fade(0.5)) // Image loading mode. Default is `single`.
  5. UnsplashConfig.default.fixed = .none

Start getting images

  1. let imageView = UIImageView()
  2. // ...
  3. imageView.unsplash.start()

Stop getting images (if gallery mode enabled)

  1. imageView.unsplash.stop()

With custom configuration

  1. var config = UnsplashConfig()
  2. config.query = .randomFromUser(username: "ari_spada")
  3. config.mode = .single(transition: .none)
  4. config.fixed = .daily
  5. imageView.unsplash.start(with: config)

Modes

  • single. Get a single image.
  • gallery. Get a new image every x seconds.

Queries

  • 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.

Updates

  • 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.

Author

adboco@telefonica.net, Adrián Bouza Correa

License

UnsplashImageView is available under the MIT license. See the LICENSE file for more info.

FOSSA Status