测试已测试 | ✗ |
Lang语言 | Obj-CObjective C |
许可证 | MIT |
发布上次发布 | 2015 年 3 月 |
由 Andres Brun 维护。
ViewController 的子类,提供当用户在 UITableView 中滚动时隐藏工具栏的行为。
为了安装此组件,您只需要下载 ABFullScrollViewController 文件夹并将其复制到您的项目中。然后您需要从 ABFullScrollViewController 继承您的视图控制器。
#import "ABFullScrollViewController.h"
@interface ViewController : ABFullScrollViewController <UITableViewDataSource>
@end
在 .m 文件中,您需要实现允许您自定义行为的类,例如
//The view that you want to set in toolbar view
-(UIView *) headerView:(UIView *)view forTableView:(UITableView *)tableView
{
[view setFrame:CGRectMake(0, 0, self.tableView.frame.size.width, HEADER_STANDARD_HEIGHT)];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0,
20/*status bar*/,
view.frame.size.width,
view.frame.size.height-20)];
[label setFont:[UIFont fontWithName:@"Copperplate" size:20]];
[label setTextColor:[UIColor blackColor]];
[label setTextAlignment:NSTextAlignmentCenter];
[label setText:@"ABFullScrollViewController"];
[view addSubview:label];
return view;
}
//The height of the toolbar view
-(float) headerHeightForTableView:(UITableView *)tableView
{
return HEADER_STANDARD_HEIGHT;
}
//The color background color of the toolbar
- (UIColor *)toolbarBackgroundColor
{
return [UIColor colorWithWhite:1.0 alpha:0.7];
}
//The minimum size that you want to show of the toolbar
- (float)minHeightWithoutHide
{
return 20 /*status bar height*/;
}
对于最后一个,您需要将 tableViewDelegate、工具栏和 tableView 链接到 .xib 文件。
此组件使用 scrollViewDidScroll:、scrollViewDidEndDragging: willDecelerate: 和 scrollViewDidEndDecelerating,因此如果您需要在您的类中实现它,请记住调用它的 super ()
此组件与 Autolayout 不兼容 :(。
ABFullScrollViewController 在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。