GSGrid 0.1.0

GSGrid 0.1.0

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最新发布2017年3月

Daniel Clelland 维护。



GSGrid 0.1.0

  • 作者
  • Daniel Clelland

GSGrid 是一组基本的 struct,用于帮助构建基本的网格布局。

它允许您指定一个具有指定行数和列数、边界以及间距宽度和高度的 GSGrid 结构,然后在该网格内计算 CGRect

例如

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}}

此代码返回一个 2x2 的网格中第一个单元,面积为 60pt,垂直和水平间距为 2pt。

自动处理将矩形四舍五入到整数像素数的工作,以确保相邻矩形间出现恒定的间距。

API

构造函数

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);