PopUpCollectionView 0.2.0

PopUpCollectionView 0.2.0

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Jun 2017
SwiftSwift Version 3.0
SPMSupports SPM

Maintained by Lawrence Tran.



  • By
  • Lawrence Tran

Pop-Up Collection View

Pop-Up Collection View is a replacement for the traditional navigation collection view style and is written in Swift 2.0.

Features

  • Coolness
  • Fast and lightweight
  • Preserves content animations (see below)

Usage

Pop-Up Collection View mimics the behavior of a normal collection view. Instantiate via code or in the interface builder. Do not forget to set the delegate and data source.

// Init Pop-Up Collection View
let popUpCollectionView = PopUpCollectionView(frame: CGRectZero)
popUpCollectionView.delegate = self
popUpCollectionView.dataSource = self

Documentation

Variables

var delegate: PopUpCollectionViewDelegate
var dataSource: PopUpCollectionViewDataSource

Methods

func reloadData()

Refreshes Pop-Up Collection View.

Delegate

func popUpCollectionView(popUpCollectionView: PopUpCollectionView, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize

Pop-Up Collection View dynamically sets its cells. This method asks the delegate for the size of the content at the given index path. Put in any size, and Pop-Up Collection View will automatically scale it to fit its layout.

func setStatusBarHidden(hidden: Bool)

Implement this method to hide/reveal the status bar. (See the demo for implementation)

Data Source

func popUpCollectionView(popUpCollectionView: PopUpCollectionView, numberOfItemsInSection section: Int) -> Int

Set the number of items in each section. Note that Pop-Up Collection View works best when there is only one section as section headers are currently not supported.

func popUpCollectionView(popUpCollectionView: PopUpCollectionView, contentViewAtIndexPath indexPath: NSIndexPath) -> UIView

Asks the data source for the content view for a given index path. This can be any implementation of a UIView.

func popUpCollectionView(popUpCollectionView: PopUpCollectionView, infoViewForItemAtIndexPath indexPath: NSIndexPath) -> UIView

Asks the data source for the info view for the given index path. Set the view’s frame to the size for when it is displayed. Pop-Up Collection View will automatically handle scaling.

Preserving Animations

Pop-Up Collection View preserves content animations during transitions. This was tested using FLAnimatedImage.

Note, this does not work with an UIImage extension such as SwiftGif.

Demo

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

Requirements

  • Swift 2.0+
  • iOS 8.0+

Installation

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

use_frameworks!
pod "PopUpCollectionView"

Roadmap

Pop-Up Collection View is still in beta and should not be considered stable.

Author

Lawrence Tran

License

See the LICENSE file for more info.