Serrata 1.0.10

Serrata 1.0.10

Takuma Horiuchi维护。



Serrata 1.0.10

Platform Swift Cocoapods Carthage compatible License

概述

您只需通过传递必要信息即可使用它!
Serrata是一个UI库,允许您直观地查看图片。

特性

Kingfisher是一个轻量级且纯Swift实现的库。
它被用在Serrata中。我非常尊重Kingfisher!

  • 支持iPhone、iPad和iPhone X!🎉
  • 它与Twitter和LINE的图片查看器非常相似。😎

要求

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

安装

注意⚠️

Kingfisher也需安装!

CocoaPods

pod 'Serrata'

Carthage

github "horitaku46/Serrata"

使用说明

更多信息请见示例

如何在示例中使用。

guard let selectedCell = collectionView.cellForItem(at: indexPath) as? ImageCell else {
    return
}

let slideLeafs: [SlideLeaf] = images.enumerated().map { SlideLeaf(image: $0.1,
                                                                  title: "Image Title \($0.0)",
                                                                  caption: "Index is \($0.0)") }

let slideImageViewController = SlideLeafViewController.make(leafs: slideLeafs,
                                                            startIndex: indexPath.row,
                                                            fromImageView: selectedCell.imageView)

slideImageViewController.delegate = self // Please watch the following SlideLeafViewControllerDelegate.
present(slideImageViewController, animated: true, completion: nil)

SlideLeafViewController.make()的详细说明。

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

SlideLeaf的详细说明。

import UIKit

public final class SlideLeaf: NSObject {

    public var image: UIImage?
    public var imageUrlString: String?

    public var title: String
    public var caption: String


    /// If either title and caption is empty, detailView is not displayed.
    ///
    /// - Parameters:
    ///   - image: To read by a slide.
    ///   - title: Title of the image.
    ///   - caption: Caption of the image.
    public init(image: UIImage?, title: String = "", caption: String = "") {
        self.image = image
        self.title = title
        self.caption = caption
    }

    /// If either title and caption is empty, detailView is not displayed.
    ///
    /// - Parameters:
    ///   - imageUrlString: To read by a slide. It is displayed by Kingfisher.
    ///   - title: Title of the image.
    ///   - caption: Caption of the image.
    public init(imageUrlString: String?, title: String = "", caption: String = "") {
        self.imageUrlString = imageUrlString
        self.title = title
        self.caption = caption
    }
}

代理

SlideLeafViewControllerDelegate的详细说明。

extension ViewController: SlideLeafViewControllerDelegate {

    func tapImageDetailView(slideLeaf: SlideLeaf, pageIndex: Int) {
        // code...
    }

    func longPressImageView(slideLeafViewController: SlideLeafViewController, slideLeaf: SlideLeaf, pageIndex: Int) {
        // code...
    }

    func slideLeafViewControllerDismissed(slideLeaf: SlideLeaf, pageIndex: Int) {
        // code...
    }
}

作者

户川takuma

示例图片来自

许可

Serrata 在 MIT 许可下可用。有关更多信息,请参阅LICENSE文件。