SCPagingGridView 是一组 iOS UIViewController 容器、视图和辅助器。该项目包括以下组件
支持水平和垂直分页的自定义页面视图控制器。
一个 UIView 子类,根据给定的模式排列其子元素。
屏幕截图
示例代码
@implementation SCExampleGridViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor scrollViewTexturedBackgroundColor];
CGFloat height = floorf(self.view.bounds.size.height * .8f);
CGFloat width = floorf(self.view.bounds.size.width * .8f);
SCGridView *grid = [[SCGridView alloc] initWithFrame:CGRectMake(floorf((self.view.bounds.size.width - width)/2.0f), floorf((self.view.bounds.size.height - height)/2.0f), width, height)];
grid.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
grid.layer.cornerRadius = 6.0f;
grid.clipsToBounds = YES;
grid.backgroundColor = [UIColor clearColor];
grid.schema = @[ @(1), @(1), @(2) ];
grid.rowSpacing = 5.0f;
grid.colSpacing = 5.0f;
[self.view addSubview:grid];
NSMutableArray *cells = [[NSMutableArray alloc] initWithCapacity:grid.size];
UILabel *label = [[UILabel alloc] init];
label.textAlignment = UITextAlignmentCenter;
label.text = @"1st cell";
[cells addObject:label];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setTitle:@"2nd cell" forState:UIControlStateNormal];
[button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[button setTitleColor:[UIColor blueColor] forState:UIControlStateHighlighted];
button.backgroundColor = [UIColor whiteColor];
[cells addObject:button];
label = [[UILabel alloc] init];
label.numberOfLines = 0;
label.textAlignment = UITextAlignmentCenter;
label.text = @"3rd cell";
[cells addObject:label];
label = [[UILabel alloc] init];
label.numberOfLines = 0;
label.textAlignment = UITextAlignmentCenter;
label.text = @"4th cell";
[cells addObject:label];
grid.cells = cells;
}
@end
一个视图控制器容器,支持在可分页的网格视图中排列一系列单元格。
屏幕截图
一个回收视图的类。它与 UITableView 的可重用单元格系统类似,但可以用于任何视图类型。
要使用 SCPagingGridView,将 source/
文件添加到您的 XCode 项目中。首选方法是在 Git 子模块中设置并参考文献。 git submodule add https://github.com/scribd/SCPagingGridView.git SCPagingGridView
SCPagingGridView 需要 iOS 5.0+ 和 Xcode 4.3+。项目使用 ARC,但可以通过在 *.m 文件上设置编译器标志 -fobjc-arc
来与不支持 ARC 的项目一起使用。您可以在目标 -> 编译方式 -> 编译源代码下设置此标志
SCPagingGridView 被以下应用使用
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.