水平或垂直滑块视图,用于选择分类。可以添加任何 UIView 类型的分类项目视图。完全可定制
将 CategorySliderView.h/m 文件复制到您的项目中。
UILabel *category1 = ......
UILabel *category2 = ......
UILabel *category3 = ......
...
CategorySliderView *sliderView = [[CategorySliderView alloc] initWithSliderHeight:60 andCategoryViews:@[category1, category2, category3] categorySelectionBlock:^(UIView *categoryView, NSInteger categoryIndex) {
UILabel *selectedView = (UILabel *)categoryView;
NSLog(@"\"%@\" cateogry selected at index %d", selectedView.text, categoryIndex);
}];
[self.view addSubview:sliderView];
您可以添加任意数量的项目
UIView *newCategoryView = .....
[sliderView addCategoryView:newCategoryView];
shouldAutoScrollSlider: scrolls to closest category item after dragging ends
shouldAutoSelectScrolledCategory: selects the closest category item after dragging ends
categoryViewPadding: padding between category item views
backgroundImage: background image for slider