Latest 0.1.0
License MIT
Platforms ios 7.0, requires ARC

GSGrid is a set of basic structs to help build basic grid layouts.

It allows you to specify a GSGrid structure with a number of rows and columns, a bounds, and a gutter width and height, and then calculate CGRects within that grid.

For example:

GSGrid grid = GSGridMake(GSGridSizeMake(2, 2), CGRectMake(0.0, 0.0, 60.0, 60.0), CGSizeMake(2.0, 2.0));

CGRect rect = CGRectWithGridRectInGrid(GSGridRectMake(0, 0, 1, 1), grid);

NSLog(@"%@", NSStringFromCGRect(rect));

> {{0, 0}, {29, 29}}

This returns the first cell in a 2 by 2 grid of 60pt square, with a vertical and horizontal gutter of 2pt.

The hard work of rounding the rect to integer number of pixels is taken care of automatically, so that a constant gutter appears between adjacent rects.



GSGridPoint GSGridPointMake(NSInteger x, NSInteger y);
GSGridSize GSGridSizeMake(NSInteger columns, NSInteger rows);
GSGridRect GSGridRectMake(NSInteger x, NSInteger y, NSInteger columns, NSInteger rows);
GSGrid GSGridMake(GSGridSize size, CGRect bounds, CGSize gutter);


CGRect CGRectWithGridRectInGrid(GSGridRect rect, GSGrid grid);
CGRect CGRectWithIndexInGrid(NSUInteger index, GSGrid grid);

Latest podspec

    "name": "GSGrid",
    "version": "0.1.0",
    "summary": "Basic CGRect grid layout helpers.",
    "homepage": "",
    "license": {
        "type": "MIT"
    "authors": {
        "Daniel Clelland": "[email protected]"
    "source": {
        "git": "",
        "tag": "0.1.0"
    "platforms": {
        "ios": "7.0"
    "ios": {
        "source_files": "GSGrid/*.{h,m}"
    "requires_arc": true

Pin It on Pinterest

Share This