YBookmarkView
示例
要运行示例项目,首先克隆仓库,然后从Example目录运行pod install
。
需求
安装
YBookmarkView可通过CocoaPods获得。要安装它,只需在Podfile中添加以下行:
pod 'YBookmarkView'
用法
1、创建初始化BookmarkView
- (YBookmarkView *)bookmarkView
{
if (!_bookmarkView) {
_bookmarkView = [[YBookmarkView alloc] initWithFrame:self.view.frame];
_bookmarkView.dataSource = self;
_bookmarkView.delegate = self;
[_bookmarkView configMake:^(YBBookMarkConfig *config) {
config.topViewHeight = 50;
config.titleSelectFont = [UIFont systemFontOfSize:17];
// config.fixedTitleWidth = 100; //如果标题是固定宽度设置
// 还有很多参数可以设置,自己体会吧 😊
}];
}
return _bookmarkView;
}
2、实现几个DataSource方法
/**
bookMarkView 数据来源
@param bookMarkView bookMarkView
@return 控制器数量
*/
- (NSInteger)numberOfItemInBookMarkView:(YBookmarkView *)bookMarkView;
/**
top title 标签
@param bookMarkView bookMarkView
@param index 第几个标签
@return title
*/
- (NSString *)bookMarkView:(YBookmarkView *)bookMarkView titleAtIndex:(NSInteger)index;
/**
控制器 数据来源
说明:每个控制器不会重复调用
@param bookMarkView bookMarkView
@param index 第几个标签
@param viewRect 控制器的CGRect 大小
@return 控制器
*/
- (UIViewController *)bookMarkView:(YBookmarkView *)bookMarkView viewAtIndex:(NSInteger)index viewRect:(CGRect)viewRect;
3、装载数据
[self.bookmarkView reloadData];
4、YBookMarkViewDelegate 回调
//** 点击 title 回调 */
- (void)bookMarkView:(YBookmarkView *)bookMarkView didSelectTitleAtIndex:(NSInteger)index;
//** 滚动到第几个标签回调 */
- (void)bookMarkView:(YBookmarkView *)bookMarkView didScrollToIndex:(NSInteger)index;
//** bottomMark 滑动结束 回调*/
- (void)bookMarkView:(YBookmarkView *)bookMarkView didEndDecelerating:(NSInteger)index;
- (void)bookMarkView:(YBookmarkView *)bookMarkView updateLayoutIndex:(NSInteger)index viewController:(UIViewController *)vc;
//** bottomMark 将要显示 回调*/
- (void)bookMarkView:(YBookmarkView *)bookMarkView bottomMarkWillDisplayCell:(UICollectionViewCell *)cell atIndex:(NSInteger)index;
//** 第index个子控制器 将要显示 回调*/
- (void)bookMarkView:(YBookmarkView *)bookMarkView willDisplayingVC:(__kindof UIViewController *)vc index:(NSInteger)index;
//** 第index个子控制 结束显示 回调*/
- (void)bookMarkView:(YBookmarkView *)bookMarkView didEndDisplayingVC:(__kindof UIViewController *)vc index:(NSInteger)index;
作者
Ethanbing, [email protected]
许可证
YBookmarkView遵循MIT许可。有关更多信息,请参阅LICENSE文件。