BoxesView 0.1.1

BoxesView 0.1.1

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Nov 2016
SwiftSwift Version 2.3
SPMSupports SPM

Maintained by Lammert Westerhoff.




BoxesView 0.1.1

BoxesView is a UIView for iOS that lays out subviews as boxes, much like a simplified version of a UICollectionView.

It completely layed out using auto layout constraints and therefore fits in modern apps. It's a simplified version of a UICollectionView that doesn't need any delegate or data source. You just configure the number of columns you want and set the views that you want to be displayed in boxes.

Screenshot 1 Screenshot 2

Requirements

  • Swift 2.0
  • iOS 8.0+
  • Xcode 7.2+

Installation

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

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

pod "BoxesView"

Then, run the following command:

$ pod install

Usage

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

Add to your project

Use the BoxesView in your project as you would use any other UIView. For example in a Storyboard. The BoxesView has an intrinsic height so you do not have to specify a height for it (although you can give it a explicit height). The simple assign the boxes views to it:

@IBOutlet weak var boxesView: BoxesView! {
    didSet {
        boxesView.boxes = [
            view1,
            someImageView,
            view2
        ]
    }
}

The boxes will be layed out in a similar fashion as in a Collection View.

Options

There are a few options available to a BoxesView. These are all variables with @IBInspectable and thus can be set in your Storyboard.

  • [x] columns Determines the number of columns that your BoxesView should have. Defaults to 2
  • [x] rowHeight Use this to specify a fixed row height. If you specify -1 (which is the default) your box views need to have an (intrinsic) height and the row height will be determined by the box in the row with the greatest height.

Dependency

This library depends on SnapKit to create the necessary auto layout constraints.

Author

Lammert Westerhoff, [email protected]

License

BoxesView is available under the MIT license. See the LICENSE file for more info.