测试测试通过 | ✗ |
语言语言 | Obj-CObjective C |
许可证 | MIT |
发布时间上一次发布 | 2017年9月 |
依赖项 | |
SDWebImage | = 3.8.2 |
Masonry | = 1.0.2 |
1. 导入类
#import "YANScrollMenu.h"
2. 直接像设置一个普通的UIView那样初始化一个 YANScrollMenu
self.menu = [[YANScrollMenu alloc] initWithFrame:CGRectMake(0, 0, 375,150) delegate:self];
# add to view
[self.view addSubview:self.menu];
# you can also set to be a tableHeaderView
self.tableView.tableHeaderView = self.menu;
3. 必须采用 YANScrollMenuDataSource
# the number of items in each section
- (NSUInteger)scrollMenu:(YANScrollMenu *)menu numberOfItemsInSection:(NSInteger)section;
# the number of section
- (NSUInteger)numberOfSectionsInScrollMenu:(YANScrollMenu *)menu;
# the dataSource of item
- (id<YANObjectProtocol>)scrollMenu:(YANScrollMenu *)scrollMenu objectAtIndexPath:(NSIndexPath *)indexPath;
4. 《YANScrollMenuDelegate》中也有一些可以用来定制的函数
# the size of item
- (CGSize)itemSizeOfScrollMenu:(YANScrollMenu *)menu;
# the customize view to set to be the header in each section
- (UIView *)scrollMenu:(YANScrollMenu *)menu headerInSection:(NSUInteger)section;
# the height of header
- (CGFloat)heightOfHeaderInScrollMenu:(YANScrollMenu *)menu;
# the height of pageControl
- (CGFloat)heightOfPageControlInScrollMenu:(YANScrollMenu *)menu;
# automatic update frame or not
- (BOOL)shouldAutomaticUpdateFrameInScrollMenu:(YANScrollMenu *)menu;
# the callback when the item did selected
- (void)scrollMenu:(YANScrollMenu *)menu didSelectItemAtIndexPath:(NSIndexPath *)indexPath;
5. 自定义外观
# the icon size of item
[[YANMenuItem appearance] setIconSize:30];
# the cornerRadius of icon
[[YANMenuItem appearance] setIconCornerRadius:15];
# the textFont of the label
[[YANMenuItem appearance] setTextFont:[UIFont systemFontOfSize:12]];
# the textColor of the label
[[YANMenuItem appearance] setTextColor:[UIColor darkTextColor]];
# the space between icon and label
[[YANMenuItem appearance] setSpace:5];
YANScrollMenu 依赖于 SDWebImage
和 Masonry
. 注意:当 SDWebImage
的版本大于 3.8.2
时,将不支持 gif。
YANScrollMenu 根据 MIT 许可证发布。请参阅 LICENSE 文件以获取详细信息。
有任何建议或问题?请创建一个 GitHub 问题 。