ProductPromotion
Logo

Swift

made by https://0x3d.site

GitHub - tungvoduc/DTPhotoViewerController: A fully customizable photo viewer ViewController to display single photo or collection of photos, inspired by Facebook photo viewer.
A fully customizable photo viewer ViewController to display single photo or collection of photos, inspired by Facebook photo viewer. - tungvoduc/DTPhotoViewerController
Visit Site

GitHub - tungvoduc/DTPhotoViewerController: A fully customizable photo viewer ViewController to display single photo or collection of photos, inspired by Facebook photo viewer.

GitHub - tungvoduc/DTPhotoViewerController: A fully customizable photo viewer ViewController to display single photo or collection of photos, inspired by Facebook photo viewer.

DTPhotoViewerController

Version License Platform

Example

Screenshot

Demo video: https://youtu.be/aTLx4M4zsKk

DTPhotoViewerController is very simple to use, if you want to display only one image in the photo viewer, all you need to do is to pass UIImageView and UIImage instances:

if let viewController = DTPhotoViewerController(referencedView: imageView, image: image) {
    self.presentViewController(viewController, animated: true, completion: nil)
}

For multiple images, what you have to do is providing an dataSource to the DTPhotoViewerController instance. DTPhotoViewerControllerDataSource has three required methods and one optional method, here is an example how to implement them which is also available in the Demo:

func photoViewerController(_ photoViewerController: DTPhotoViewerController, referencedViewForPhotoAt index: Int) -> UIView? {
    let indexPath = IndexPath(item: index, section: 0)
    if let cell = self.collectionView?.cellForItem(at: indexPath) as? CollectionViewCell {
        return cell.imageView
    }

    return nil
}

func numberOfItems(in photoViewerController: DTPhotoViewerController) -> Int {
    return images.count
}

func photoViewerController(_ photoViewerController: DTPhotoViewerController, configureCell cell: DTPhotoCollectionViewCell, forPhotoAt index: Int) {
     // You need to implement this method usually when using custom DTPhotoCollectionViewCell and configure each photo differently.
}

func photoViewerController(_ photoViewerController: DTPhotoViewerController, configurePhotoAt index: Int, withImageView imageView: UIImageView) {
    imageView.image = images[index]
}

In case you want to add more UI elements to each photo, the best way is to create a subclass of DTPhotoCollectionViewCell and then call either one of these methods registerClassPhotoViewer: or registerNibForPhotoViewer:

if let viewController = BDFPostPhotoViewerController(referencedView: cell.imageView, image: cell.imageView.image) {
     viewController.registerClassPhotoViewer(DTCustomPhotoCollectionViewCell.self)
}

There is also delegate(DTPhotoViewerControllerDelegate) if you want to customize the behavior of DTPhotoViewerController.

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

CocoaPods

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

For Swift 5:

pod "DTPhotoViewerController"

For Swift 4.2:

pod 'DTPhotoViewerController', '~> 1.2.5'

Swift package manager

DTPhotoViewerController is available for SPM from version 3.0.2. Add the following to the dependencies of your Package.swift:

.package(url: "https://github.com/tungvoduc/DTPhotoViewerController", from: "version")

Author

Tung Vo, [email protected]

License

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

Feedbacks & requests

  • Open an issue if you find a bug, make a proposal or simply need some help.
  • You can also contact me via email.

More Resources
to explore the angular.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here ๐Ÿ”.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory