Latest 3.3.1
Homepage https://github.com/Inspirato/SwiftPhotoGallery
License Apache-2.0
Platforms ios 9.0, tvos 10.0, requires ARC
Frameworks UIKit, Foundation
Authors

Platform
Version
License
CocoaPods
tests
Swift
Dependencies

Overview

A full screen photo gallery for iOS and tvOS written in Swift.

SwiftPhotoGallery

  • Photos can be panned and zoomed (iOS only)
  • Pinch to zoom (iOS only)
  • Double tap to zoom all the way in and again to zoom all the way out (iOS only)
  • Single tap to close
  • Twitter style swipe to close (iOS only)
  • Includes a customizable page indicator
  • Support for any orientation (iOS only)
  • Supports images of varying sizes
  • Includes unit tests
  • Customize nearly all UI aspects
  • Integrates seamlessly with SDWebImage

Usage

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

Requirements

  • iOS 9.0+
  • tvOS 10.0+
  • Xcode 9.0+
  • Swift 4.0+

Communication

  • If you need help, use Stack Overflow. (Tag ‘swiftphotogallery’)
  • If you’d like to ask a general question, use Stack Overflow.
  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

Installation

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

pod 'SwiftPhotoGallery'

Implementation

  • Import the framework in your view controller

    import SwiftPhotoGallery
  • Create an instance

    let gallery = SwiftPhotoGallery(delegate: self, dataSource: self)
  • Customize the look

    gallery.backgroundColor = UIColor.blackColor()
    gallery.pageIndicatorTintColor = UIColor.grayColor().colorWithAlphaComponent(0.5)
    gallery.currentPageIndicatorTintColor = UIColor.whiteColor()
    gallery.hidePageControl = false
  • Implement the datasource
    
    let imageNames = ["image1.jpeg", "image2.jpeg", "image3.jpeg"]

func numberOfImagesInGallery(gallery: SwiftPhotoGallery) -> Int {
return imageNames.count
}

func imageInGallery(gallery: SwiftPhotoGallery, forIndex: Int) -> UIImage? {
return UIImage(named: imageNames[forIndex])
}


* **Implement the delegate**
```swift
func galleryDidTapToClose(gallery: SwiftPhotoGallery) {
    // do something cool like:
    dismiss(animated: true, completion: nil)
}
  • Present the gallery
    present(gallery, animated: true, completion: nil)

Full Example

class ViewController: UIViewController, SwiftPhotoGalleryDataSource, SwiftPhotoGalleryDelegate {

    let imageNames = ["image1.jpeg", "image2.jpeg", "image3.jpeg"]
    var index: Int = 2

    override func viewDidLoad() {
        super.viewDidLoad()
    }

    @IBAction func didPressShowMeButton(sender: AnyObject) {
        let gallery = SwiftPhotoGallery(delegate: self, dataSource: self)

        gallery.backgroundColor = UIColor.blackColor()
        gallery.pageIndicatorTintColor = UIColor.grayColor().colorWithAlphaComponent(0.5)
        gallery.currentPageIndicatorTintColor = UIColor.whiteColor()
        gallery.hidePageControl = false

        present(gallery, animated: true, completion: nil)

        /*
        /// Or load on a specific page like this:

        present(gallery, animated: true, completion: { () -> Void in
            gallery.currentPage = self.index
        })
        */

    }

    // MARK: SwiftPhotoGalleryDataSource Methods

    func numberOfImagesInGallery(gallery: SwiftPhotoGallery) -> Int {
        return imageNames.count
    }

    func imageInGallery(gallery: SwiftPhotoGallery, forIndex: Int) -> UIImage? {
        return UIImage(named: imageNames[forIndex])
    }

    // MARK: SwiftPhotoGalleryDelegate Methods

    func galleryDidTapToClose(gallery: SwiftPhotoGallery) {
        dismiss(animated: true, completion: nil)
    }

}

Author

Justin Vallely, [email protected]

License

SwiftPhotoGallery is available under the Apache License 2.0. See the LICENSE file for more info.

Latest podspec

{
    "name": "SwiftPhotoGallery",
    "version": "3.3.1",
    "summary": "Photo gallery for iOS and tvOS written in Swift",
    "description": ""Photo gallery for iOS and tvOS written in Swift. Photos can be panned and zoomed (iOS). Includes a customizable page indicator, support for any orientation (iOS), and supports images of varying sizes. Includes unit tests."",
    "homepage": "https://github.com/Inspirato/SwiftPhotoGallery",
    "license": "Apache-2.0",
    "authors": {
        "Justin Vallely": "[email protected]"
    },
    "source": {
        "git": "https://github.com/Inspirato/SwiftPhotoGallery.git",
        "tag": "3.3.1"
    },
    "platforms": {
        "ios": "9.0",
        "tvos": "10.0"
    },
    "requires_arc": true,
    "source_files": "Pod/Classes/**/*",
    "frameworks": [
        "UIKit",
        "Foundation"
    ],
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This