DAImageGallery – a simple image gallery for Swift

Custom Image Gallery in Swift

Recently I have created an image gallery for Swift called DAImageGallery and you can find it here. I’ve made it so simple, you will need a minute to integrate it into your project.
Just download the test project from Github, and import the following files:

  • XibSetupView.swift
  • DAImageGallery.swift
  • DAImageGallery.xib

Then all you need to do is to initialize the DAImageGallery object.

var imageGallery: DAImageGallery!
override func viewDidLoad(){
    imageGallery = DAImageGallery(frame: CGRectZero)
    boundInside(self.view, subview: imageGallery)

The boundInside method adds constraints to match the subview to the size of the superview.

func boundInside(superView: UIView, subview: UIView){
    subview.translatesAutoresizingMaskIntoConstraints = false
    superView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|-0-[subview]-0-|", options: NSLayoutFormatOptions.DirectionLeadingToTrailing, metrics:nil, views:["subview":subview]))
    superView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|-0-[subview]-0-|", options: NSLayoutFormatOptions.DirectionLeadingToTrailing, metrics:nil, views:["subview":subview]))

Would appreciate if you comment on what you think about it, and also tell me what you want to be added to this simple image gallery.

Leave a Reply

Your email address will not be published. Required fields are marked *