项目作者: horitaku46

项目描述 :
Slide image viewer library similar to Twitter and LINE.
高级语言: Swift
项目地址: git://github.com/horitaku46/Serrata.git
创建时间: 2017-12-14T06:01:57Z
项目社区:https://github.com/horitaku46/Serrata

开源协议:MIT License

下载




Platform
Swift
Cocoapods
Carthage compatible
License

Overview

You can use it simply by passing the necessary information!
Serrata is a UI library that allows you to intuitively view images.





Features

Kingfisher is a lightweight and pure Swift implemented library.
It is used in the Serrata. I sincerely respect Kingfisher!

  • Support iPhone, iPad and iPhone X! 🎉
  • It is the almost same as Image Viewer of Twitter and LINE.😎

Requirements

  • Xcode 9.0+
  • iOS 11+
  • Swift 4.0+

Installation

Caution ⚠️

Kingfisher is installed, too!

CocoaPods

  1. pod 'Serrata'

Carthage

  1. github "horitaku46/Serrata"

Usage

See Example, for more details.

How to use in Example.

  1. guard let selectedCell = collectionView.cellForItem(at: indexPath) as? ImageCell else {
  2. return
  3. }
  4. let slideLeafs: [SlideLeaf] = images.enumerated().map { SlideLeaf(image: $0.1,
  5. title: "Image Title \($0.0)",
  6. caption: "Index is \($0.0)") }
  7. let slideImageViewController = SlideLeafViewController.make(leafs: slideLeafs,
  8. startIndex: indexPath.row,
  9. fromImageView: selectedCell.imageView)
  10. slideImageViewController.delegate = self // Please watch the following SlideLeafViewControllerDelegate.
  11. present(slideImageViewController, animated: true, completion: nil)

Details of SlideLeafViewController.make().

  1. /// This method generates SlideLeafViewController.
  2. ///
  3. /// - Parameters:
  4. /// - leafs: It is array to display it by a slide.
  5. /// - startIndex: It is for initial indication based on array of leafs.
  6. /// - fromImageView: ImageView of the origin of transition. In the case of nil, CrossDissolve.
  7. /// - Returns: Instance of SlideLeafViewController.
  8. open class func make(leafs: [SlideLeaf], startIndex: Int = 0, fromImageView: UIImageView? = nil) -> SlideLeafViewController {
  9. // code...
  10. }

Details of SlideLeaf.

  1. import UIKit
  2. public final class SlideLeaf: NSObject {
  3. public var image: UIImage?
  4. public var imageUrlString: String?
  5. public var title: String
  6. public var caption: String
  7. /// If either title and caption is empty, detailView is not displayed.
  8. ///
  9. /// - Parameters:
  10. /// - image: To read by a slide.
  11. /// - title: Title of the image.
  12. /// - caption: Caption of the image.
  13. public init(image: UIImage?, title: String = "", caption: String = "") {
  14. self.image = image
  15. self.title = title
  16. self.caption = caption
  17. }
  18. /// If either title and caption is empty, detailView is not displayed.
  19. ///
  20. /// - Parameters:
  21. /// - imageUrlString: To read by a slide. It is displayed by Kingfisher.
  22. /// - title: Title of the image.
  23. /// - caption: Caption of the image.
  24. public init(imageUrlString: String?, title: String = "", caption: String = "") {
  25. self.imageUrlString = imageUrlString
  26. self.title = title
  27. self.caption = caption
  28. }
  29. }

delegate

Detail of SlideLeafViewControllerDelegate.

  1. extension ViewController: SlideLeafViewControllerDelegate {
  2. func tapImageDetailView(slideLeaf: SlideLeaf, pageIndex: Int) {
  3. // code...
  4. }
  5. func longPressImageView(slideLeafViewController: SlideLeafViewController, slideLeaf: SlideLeaf, pageIndex: Int) {
  6. // code...
  7. }
  8. func slideLeafViewControllerDismissed(slideLeaf: SlideLeaf, pageIndex: Int) {
  9. // code...
  10. }
  11. }

Author

Takuma Horiuchi

Example images from

License

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