Latest 0.0.9
Homepage https://github.com/zhangao0086/DKPhotoGallery
License MIT
Platforms ios 8.0, requires ARC
Dependencies SDWebImage/GIF
Frameworks Foundation, UIKit, Photos, WebKit, AVFoundation, AVKit, AssetsLibrary, MobileCoreServices
Authors

Build Status Version Status license MIT


Features

  • PNG|JPEG|GIF|PHAsset
  • AVPlayer
  • PDF
  • Image caching with SDWebImage
  • Original image download
  • Extract QR Code(Text、URL)
  • Incremental fetching items
  • Localization
  • 3D Touch

Requirements

  • iOS 8.0+
  • ARC
  • Swift 3.2 & 4.2

Installation

iOS 8 and newer

DKPhotoGallery is available on CocoaPods. Simply add the following line to your podfile:

# For latest release in cocoapods
pod 'DKPhotoGallery'

Usage

let gallery = DKPhotoGallery()
gallery.singleTapMode = .dismiss
gallery.items = self.items
gallery.presentingFromImageView = self.imageView
gallery.presentationIndex = 0

gallery.finishedBlock = { dismissIndex, dismissItem in
    if item == dismissItem {
        return imageView
    } else {
        return nil
    }
}

self.present(photoGallery: gallery)

DKPhotoGalleryItem

Create a DKPhotoGalleryItem with a UIImage or a URL or a PHAsset.

@objc
open class DKPhotoGalleryItem: NSObject {

    /// The image to be set initially, until the image request finishes.
    open var thumbnail: UIImage?

    open var image: UIImage?
    open var imageURL: URL?

    open var videoURL: URL?

    /// iOS 11 or higher required.
    @objc open var pdfURL: URL?

    /**
     DKPhotoGallery will automatically decide whether to create ImagePreview or PlayerPreview via the mediaType of the asset.

     See more: DKPhotoPreviewFactory.swift
     */
    open var asset: PHAsset?
    open var assetLocalIdentifier: String?

    /**
     Used for some optional features.

     For ImagePreview, you can enable the original image download feature with a key named DKPhotoGalleryItemExtraInfoKeyRemoteImageOriginalURL.
     */
    open var extraInfo: [String: Any]?
}

Extract QR Code

Enable the original image download

let item = DKPhotoGalleryItem(imageURL: URL(string:"https://sz-preview.oss-cn-hangzhou.aliyuncs.com/pics/10003/b29259d837d4aaeef4b33c9dbc964a5b?x-oss-process=image/resize,m_lfit,h_512,w_512/quality,Q_80")!)
item.extraInfo = [
    DKPhotoGalleryItemExtraInfoKeyRemoteImageOriginalURL: URL(string:"https://sz-preview.oss-cn-hangzhou.aliyuncs.com/pics/10003/b29259d837d4aaeef4b33c9dbc964a5b")!
]

Localization

The default supported languages:

  • en.lproj
  • zh-Hans.lproj

You can also add a hook to return your own localized strings:

DKPhotoGalleryResource.customLocalizationBlock = { title in
    if title == "preview.image.longPress.cancel" {
        return "This is a test."
    } else {
        return nil
    }
}

License

DKPhotoGallery is released under the MIT license. See LICENSE for details.

Latest podspec

{
    "name": "DKPhotoGallery",
    "version": "0.0.9",
    "summary": "A Photo Gallery / Browser / Viewer for iOS written in Swift",
    "homepage": "https://github.com/zhangao0086/DKPhotoGallery",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Bannings": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/zhangao0086/DKPhotoGallery.git",
        "tag": "0.0.9"
    },
    "frameworks": [
        "Foundation",
        "UIKit",
        "Photos",
        "WebKit",
        "AVFoundation",
        "AVKit",
        "AssetsLibrary",
        "MobileCoreServices"
    ],
    "requires_arc": true,
    "swift_version": "4.2",
    "dependencies": {
        "SDWebImage/GIF": []
    },
    "subspecs": [
        {
            "name": "Core",
            "dependencies": {
                "DKPhotoGallery/Model": [],
                "DKPhotoGallery/Preview": []
            },
            "source_files": [
                "DKPhotoGallery/DKPhotoGallery.swift",
                "DKPhotoGallery/DKPhotoGalleryContentVC.swift",
                "DKPhotoGallery/DKPhotoGalleryScrollView.swift",
                "DKPhotoGallery/DKPhotoPreviewFactory.swift",
                "DKPhotoGallery/DKPhotoIncrementalIndicator.swift",
                "DKPhotoGallery/Transition/*.swift"
            ]
        },
        {
            "name": "Model",
            "source_files": "DKPhotoGallery/DKPhotoGalleryItem.swift"
        },
        {
            "name": "Preview",
            "dependencies": {
                "DKPhotoGallery/Model": [],
                "DKPhotoGallery/Resource": []
            },
            "source_files": "DKPhotoGallery/Preview/**/*.swift"
        },
        {
            "name": "Resource",
            "source_files": "DKPhotoGallery/Resource/*.swift",
            "resources": "DKPhotoGallery/Resource/DKPhotoGallery.bundle"
        }
    ]
}

Pin It on Pinterest

Share This