Latest | 0.1.0 |
---|---|
Homepage | https://github.com/dclelland/GSGrid |
License | MIT |
Platforms | ios 7.0, requires ARC |
Authors |
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 CGRect
s 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.
API
Constructors
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);
Functions
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": "https://github.com/dclelland/GSGrid", "license": { "type": "MIT" }, "authors": { "Daniel Clelland": "[email protected]" }, "source": { "git": "https://github.com/dclelland/GSGrid.git", "tag": "0.1.0" }, "platforms": { "ios": "7.0" }, "ios": { "source_files": "GSGrid/*.{h,m}" }, "requires_arc": true }
Sat, 05 Mar 2016 22:51:03 +0000