All Projects → tungvoduc → Dtphotoviewercontroller

tungvoduc / Dtphotoviewercontroller

Licence: mit
A fully customizable photo viewer ViewController to display single photo or collection of photos, inspired by Facebook photo viewer.

Programming Languages

swift
15916 projects
swift4
162 projects

Projects that are alternatives of or similar to Dtphotoviewercontroller

Containercontroller
UI Component. This is a copy swipe-panel from app: Apple Maps, Stocks. Swift version
Stars: ✭ 273 (+28.77%)
Mutual labels:  xcode, cocoapods, swift-package-manager
Cdmarkdownkit
An extensive Swift framework providing simple and customizable markdown parsing.
Stars: ✭ 158 (-25.47%)
Mutual labels:  xcode, cocoapods, swift-package-manager
Swift5 Module Template
An opinionated starting point for awesome, reusable Swift 5 modules
Stars: ✭ 331 (+56.13%)
Mutual labels:  xcode, cocoapods, swift-package-manager
Swiftlyext
SwiftlyExt is a collection of useful extensions for Swift 3 standard classes and types 🚀
Stars: ✭ 31 (-85.38%)
Mutual labels:  xcode, cocoapods, swift-package-manager
Xmlmapper
A simple way to map XML to Objects written in Swift
Stars: ✭ 90 (-57.55%)
Mutual labels:  xcode, cocoapods, swift-package-manager
Roundcode
Custom rounded QR code with lots of customization.
Stars: ✭ 267 (+25.94%)
Mutual labels:  xcode, cocoapods, swift-package-manager
Bfkit Swift
BFKit-Swift is a collection of useful classes, structs and extensions to develop Apps faster.
Stars: ✭ 963 (+354.25%)
Mutual labels:  xcode, cocoapods, swift-package-manager
Dtpagercontroller
A fully customizable container view controller to display a set of ViewControllers in a horizontal scroll view. Written in Swift.
Stars: ✭ 240 (+13.21%)
Mutual labels:  xcode, cocoapods, swift-package-manager
Dtgradientbutton
Easy way to set gradient background to your buttons.
Stars: ✭ 76 (-64.15%)
Mutual labels:  xcode, cocoapods, swift-package-manager
Loadingshimmer
An easy way to add a shimmering effect to any view with just one line of code. It is useful as an unobtrusive loading indicator.
Stars: ✭ 1,180 (+456.6%)
Mutual labels:  xcode, cocoapods, swift-package-manager
Scenekit Bezier Animations
Create animations over Bezier curves of any number of points
Stars: ✭ 35 (-83.49%)
Mutual labels:  cocoapods, swift-package-manager, cocoapod
Alamofire
Elegant HTTP Networking in Swift
Stars: ✭ 36,896 (+17303.77%)
Mutual labels:  xcode, cocoapods, swift-package-manager
Swifterswift
A handy collection of more than 500 native Swift extensions to boost your productivity.
Stars: ✭ 10,706 (+4950%)
Mutual labels:  xcode, cocoapods, swift-package-manager
Natrium
A pre-build (Swift) script to alter your Xcode project at pre-build-time per environment, build configuration and target.
Stars: ✭ 131 (-38.21%)
Mutual labels:  xcode, cocoapods, swift-package-manager
Donut
Donut is a library for arranging views circularly like a donut.
Stars: ✭ 141 (-33.49%)
Mutual labels:  xcode, cocoapods
Ducttape
📦 KeyPath dynamicMemberLookup based syntax sugar for Swift.
Stars: ✭ 138 (-34.91%)
Mutual labels:  cocoapods, swift-package-manager
Calendarkit
📅 Calendar for Apple platforms in Swift
Stars: ✭ 2,049 (+866.51%)
Mutual labels:  cocoapods, swift-package-manager
Nearbyweather
NearbyWeather is an open source weather app for iOS, which uses the OpenWeatherMap API. With this project developers are invited to learn advanced iOS concepts, as well as to contribute further advancements. Fork this repo to get started.
Stars: ✭ 146 (-31.13%)
Mutual labels:  xcode, cocoapods
Abexpandableview
Expandable, collapsible, filterable and single/multi selectable table view.
Stars: ✭ 138 (-34.91%)
Mutual labels:  cocoapods, cocoapod
Cloudcore
Framework that enables syncing between iCloud (CloudKit) and Core Data
Stars: ✭ 146 (-31.13%)
Mutual labels:  cocoapods, swift-package-manager

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.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].