{"id":1516,"url":"https://github.com/tungvoduc/DTPhotoViewerController","last_synced_at":"2025-08-06T13:32:39.596Z","repository":{"id":47160654,"uuid":"58240185","full_name":"tungvoduc/DTPhotoViewerController","owner":"tungvoduc","description":"A fully customizable photo viewer ViewController to display single photo or collection of photos, inspired by Facebook photo viewer.","archived":false,"fork":false,"pushed_at":"2021-10-24T13:24:06.000Z","size":12829,"stargazers_count":280,"open_issues_count":8,"forks_count":40,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-11-24T01:52:28.415Z","etag":null,"topics":["cocoapod","cocoapods","photoviewer","swift","swift-package-manager","swift4","swift5","xcode"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tungvoduc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-06T23:29:39.000Z","updated_at":"2024-11-18T09:57:08.000Z","dependencies_parsed_at":"2022-08-20T19:50:29.275Z","dependency_job_id":null,"html_url":"https://github.com/tungvoduc/DTPhotoViewerController","commit_stats":null,"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tungvoduc%2FDTPhotoViewerController","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tungvoduc%2FDTPhotoViewerController/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tungvoduc%2FDTPhotoViewerController/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tungvoduc%2FDTPhotoViewerController/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tungvoduc","download_url":"https://codeload.github.com/tungvoduc/DTPhotoViewerController/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228905499,"owners_count":17989778,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cocoapod","cocoapods","photoviewer","swift","swift-package-manager","swift4","swift5","xcode"],"created_at":"2024-01-05T20:15:48.297Z","updated_at":"2024-12-09T14:30:59.256Z","avatar_url":"https://github.com/tungvoduc.png","language":"Swift","funding_links":[],"categories":["Media","Libs","Images [🔝](#readme)"],"sub_categories":["Image","Images","Other free courses"],"readme":"# DTPhotoViewerController\n\n[![Version](https://img.shields.io/cocoapods/v/DTPhotoViewerController.svg?style=flat)](http://cocoapods.org/pods/DTPhotoViewerController)\n[![License](https://img.shields.io/cocoapods/l/DTPhotoViewerController.svg?style=flat)](http://cocoapods.org/pods/DTPhotoViewerController)\n[![Platform](https://img.shields.io/cocoapods/p/DTPhotoViewerController.svg?style=flat)](http://cocoapods.org/pods/DTPhotoViewerController)\n\n## Example\n![Screenshot](demo.gif)\n\nDemo video: https://youtu.be/aTLx4M4zsKk\n\nDTPhotoViewerController 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:\n```swift\nif let viewController = DTPhotoViewerController(referencedView: imageView, image: image) {\n    self.presentViewController(viewController, animated: true, completion: nil)\n}\n```\n\nFor 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:\n\n```swift\nfunc photoViewerController(_ photoViewerController: DTPhotoViewerController, referencedViewForPhotoAt index: Int) -\u003e UIView? {\n    let indexPath = IndexPath(item: index, section: 0)\n    if let cell = self.collectionView?.cellForItem(at: indexPath) as? CollectionViewCell {\n        return cell.imageView\n    }\n\n    return nil\n}\n\nfunc numberOfItems(in photoViewerController: DTPhotoViewerController) -\u003e Int {\n    return images.count\n}\n\nfunc photoViewerController(_ photoViewerController: DTPhotoViewerController, configureCell cell: DTPhotoCollectionViewCell, forPhotoAt index: Int) {\n     // You need to implement this method usually when using custom DTPhotoCollectionViewCell and configure each photo differently.\n}\n\nfunc photoViewerController(_ photoViewerController: DTPhotoViewerController, configurePhotoAt index: Int, withImageView imageView: UIImageView) {\n    imageView.image = images[index]\n}\n```\n\nIn 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:\n```swift\nif let viewController = BDFPostPhotoViewerController(referencedView: cell.imageView, image: cell.imageView.image) {\n     viewController.registerClassPhotoViewer(DTCustomPhotoCollectionViewCell.self)\n}\n```\n\nThere is also delegate(DTPhotoViewerControllerDelegate) if you want to customize the behavior of DTPhotoViewerController.\n\nTo run the example project, clone the repo, and run `pod install` from the Example directory first.\n\n## Requirements\n\n## Installation\n\n### CocoaPods\nDTPhotoViewerController is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\nFor Swift 5:\n\n```ruby\npod \"DTPhotoViewerController\"\n```\n\nFor Swift 4.2:\n\n```ruby\npod 'DTPhotoViewerController', '~\u003e 1.2.5'\n```\n\n### Swift package manager\n`DTPhotoViewerController` is available for SPM from version `3.0.2`.\nAdd the following to the dependencies of your `Package.swift`:\n\n```swift\n.package(url: \"https://github.com/tungvoduc/DTPhotoViewerController\", from: \"version\")\n```\n\n## Author\n\nTung Vo, tung98.dn@gmail.com\n\n## License\n\nDTPhotoViewerController is available under the MIT license. See the LICENSE file for more info.\n\n## Feedbacks \u0026 requests\n- Open an issue if you find a bug, make a proposal or simply need some help.\n- You can also contact me via [email](mailto:tung98.dn@gmail.com).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftungvoduc%2FDTPhotoViewerController","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftungvoduc%2FDTPhotoViewerController","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftungvoduc%2FDTPhotoViewerController/lists"}