发表日期:2018-08 文章编辑:小灯 浏览次数:2563
腾讯新闻今日头条、QQ音乐、网易云音乐、京东、爱奇艺、淘宝、天猫、 、微博等所有主流APP分类切换滚动视图
与其他的同类三方库对比的优点:
下载源码,一睹为快!JXCategoryView
说明 | Gif |
---|---|
指示器LineView | ![]() |
指示器LineView京东风格 | ![]() |
指示器LineView爱奇艺风格 | ![]() |
指示器EllipseLayer | ![]() |
指示器EllipseLayer遮罩 | ![]() |
指示器EllipseLayer遮罩 (阴影) | ![]() |
指示器ImageView(小船) | ![]() |
指示器滚动效果(足球) | ![]() |
QQ黏性红点 | ![]() |
三角形底部 | ![]() |
三角形顶部 | ![]() |
文字遮罩(无背景视图) | ![]() |
背景指示图 | ![]() |
矩形指示图 | ![]() |
混合使用 | ![]() |
自定义Indicator示例-点线 | ![]() |
说明 | Gif |
---|---|
颜色渐变 | ![]() |
大小缩放 | ![]() |
分割线 | ![]() |
TitleImage_Top | ![]() |
TitleImage_Left | ![]() |
TitleImage_Bottom | ![]() |
TitleImage_Right | ![]() |
TitleImage_OnlyImage | ![]() |
图文混用 | ![]() |
自定义-数字 | ![]() |
自定义cell-红点 | ![]() |
自定义cell-背景色渐变 | ![]() |
腾讯视频效果 | ![]() |
自定义cell示例-多行+富文本 | ![]() |
说明 | Gif |
---|---|
SegmentedControl | ![]() |
导航栏使用 | ![]() |
个人主页(上下左右滚动、header悬浮) | ![]() |
嵌套使用 | ![]() |
垂直列表滚动 高仿腾讯视频 (背景色异常是录屏软件bug | ![]() |
数据源刷新&列表数据加载 示例 | ![]() |
Clone代码,把Sources文件夹拖入项目,#import "JXCategoryView.h",就可以使用了;
target '<Your Target Name>' do pod 'JXCategoryView' end
JXCategoryIndicatorProtocol
协议,就可以实现你的指示器效果。参考:JXCategoryIndicatorLineView;VerticalListViewController
,未做功能封装,参考里面的代码做,多注意注释,就可以实现了。通过将指示器的行为抽象出来,再通过JXCategoryIndicatorProtocol
协议进行约束。这样指示器效果就可以无限扩展,为所欲为的添加指示器了,不再受上一个版本继承的束缚了。更多POP内容,推荐喵神的文章面向协议编程与 Cocoa 的邂逅
属性 | 说明 |
---|---|
defaultSelectedIndex | 默认选中的index,用于初始化时指定选中某个index |
selectedIndex | 只读属性,当前选中的index |
cellWidth | cell的宽度,默认:JXCategoryViewAutomaticDimension |
cellSpacing | cell之间的间距,默认20 |
cellWidthIncrement | cell宽度的补偿值,默认0 |
averageCellWidthEnabled | 当cell内容总宽度小于JXCategoryBaseView的宽度,是否将cellWidth均分。默认为YES。 |
contentScrollView | 需要关联的contentScrollView,内部监听contentOffset |
属性 | 说明 |
---|---|
titleColor | titleLabel未选中颜色 默认:[UIColor blackColor] |
titleSelectedColor | titleLabel选中颜色 默认:[UIColor redColor] |
titleFont | titleLabel的字体 默认:[UIFont systemFontOfSize:15] |
titleColorGradientEnabled | title的颜色是否渐变过渡 默认:NO |
titleLabelMaskEnabled | titleLabel是否遮罩过滤 默认:NO |
titleLabelZoomEnabled | titleLabel是否缩放 默认:NO |
titleLabelZoomScale | citleLabel缩放比例 默认:1.2 |
imageZoomEnabled | imageView是否缩放 默认:NO |
imageZoomScale | imageView缩放比例 默认:1.2 |
separatorLineShowEnabled | cell分割线是否展示 默认:NO (颜色、宽高可以设置) |
JXCategoryTitleImageType | 图片所在位置:上面、左边、下面、右边 默认:左边 |
属性 | 说明 |
---|---|
JXCategoryIndicatorComponentView.componentPosition | 指示器的位置 默认:Bottom |
JXCategoryIndicatorComponentView.scrollEnabled | 手势滚动、点击切换的时候,是否允许滚动,默认YES |
JXCategoryIndicatorLineView.lineStyle | 普通、京东、爱奇艺效果 默认:Normal |
JXCategoryIndicatorLineView.lineScrollOffsetX | 爱奇艺效果专用,line滚动时x的偏移量,默认为10; |
JXCategoryIndicatorLineView.indicatorLineWidth | 默认JXCategoryViewAutomaticDimension(与cellWidth相等) |
JXCategoryIndicatorLineView.indicatorLineViewHeight | 默认:3 |
JXCategoryIndicatorLineView.indicatorLineViewCornerRadius | 默认JXCategoryViewAutomaticDimension (等于self.indicatorLineViewHeight/2) |
JXCategoryIndicatorLineView.indicatorLineViewColor | 默认为[UIColor redColor] |
JXCategoryIndicatorTriangleView.triangleViewSize | 默认:CGSizeMake(14, 10) |
JXCategoryIndicatorTriangleView.triangleViewColor | 默认为[UIColor redColor] |
JXCategoryIndicatorImageView.indicatorImageView | 设置image |
JXCategoryIndicatorImageView.indicatorImageViewRollEnabled | 是否允许滚动,默认:NO |
JXCategoryIndicatorImageView.indicatorImageViewSize | 默认:CGSizeMake(30, 20) |
JXCategoryIndicatorBackgroundView.backgroundViewWidth | 默认JXCategoryViewAutomaticDimension(与cellWidth相等) |
JXCategoryIndicatorBackgroundView.backgroundViewWidthIncrement | 宽度增量补偿,因为backgroundEllipseLayer一般会比实际内容大一些。默认10 |
JXCategoryIndicatorBackgroundView.backgroundViewHeight | 默认JXCategoryViewAutomaticDimension(与cell高度相等) |
JXCategoryIndicatorBackgroundView.backgroundViewCornerRadius | 默认JXCategoryViewAutomaticDimension(即backgroundViewHeight/2) |
JXCategoryIndicatorBackgroundView.backgroundViewColor | 默认为[UIColor redColor] |
JXCategoryIndicatorBallView.ballViewSize | 默认:CGSizeMake(15, 15) |
JXCategoryIndicatorBallView.ballScrollOffsetX | 小红点的偏移量 默认:20 |
JXCategoryIndicatorBallView.ballViewColor | 默认为[UIColor redColor] |
可以多个IndicatorView搭配使用,但是效果需要自己把控,效果不是越多越好。参考混合使用;
//1、初始化JXCategoryTitleView self.categoryView = [[JXCategoryTitleView alloc] initWithFrame:CGRectMake(0, 0, WindowsSize.width, categoryViewHeight)]; self.categoryView.delegate = self;//2、添加并配置指示器 //lineView JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init]; lineView.indicatorLineViewColor = [UIColor redColor]; lineView.indicatorLineWidth = JXCategoryViewAutomaticDimension; //backgroundView JXCategoryIndicatorBackgroundView *backgroundView = [[JXCategoryIndicatorBackgroundView alloc] init]; backgroundView.backgroundViewColor = [UIColor redColor]; backgroundView.backgroundViewWidth = JXCategoryViewAutomaticDimension; titleCategoryView.indicators = @[lineView, backgroundView];//3、绑定contentScrollView。self.scrollView的初始化细节参考源码。 self.categoryView.contentScrollView = self.scrollView; [self.view addSubview:self.categoryView];
- (void)reloadCell:(NSUInteger)index
reloadData
方法刷新状态。仓库自带:JXCategoryIndicatorLineView、JXCategoryIndicatorTriangleView、JXCategoryIndicatorImageView、JXCategoryIndicatorBackgroundView、JXCategoryIndicatorBallView
主要实现的方法:
JXCategoryIndicatorProtocol
协议;- (void)jx_refreshState:(CGRect)selectedCellFrame
初始化或reloadData,重置状态;- (void)jx_contentScrollViewDidScrollWithLeftCellFrame:(CGRect)leftCellFrame rightCellFrame:(CGRect)rightCellFrame selectedPosition:(JXCategoryCellClickedPosition)selectedPosition percent:(CGFloat)percent
contentScrollView在进行手势滑动时,处理指示器跟随手势变化UI逻辑;- (void)jx_selectedCell:(CGRect)cellFrame clickedRelativePosition:(JXCategoryCellClickedPosition)clickedRelativePosition
根据选中的某个cell,处理过渡效果;具体实例:参考demo工程里面的JXCategoryIndicatorDotLineView
仓库自带:JXCategoryTitleView、JXCategoryTitleImageView、JXCategoryNumberView、JXCategoryDotView、JXCategoryImageView
主要实现的方法:
- (Class)preferredCellClass
返回自定义的cell;- (void)refreshDataSource
刷新数据源,使用自定义的cellModel;- (void)refreshCellModel:(JXCategoryBaseCellModel *)cellModel index:(NSInteger)index
初始化、reloadData时对数据源重置;- (CGFloat)preferredCellWidthAtIndex:(NSInteger)index
根据cell的内容返回对应的宽度;- (void)refreshSelectedCellModel:(JXCategoryBaseCellModel *)selectedCellModel unselectedCellModel:(JXCategoryBaseCellModel *)unselectedCellModel
cell选中时进行状态刷新;- (void)refreshLeftCellModel:(JXCategoryBaseCellModel *)leftCellModel rightCellModel:(JXCategoryBaseCellModel *)rightCellModel ratio:(CGFloat)ratio
cell左右滚动切换的时候,进行状态刷新;具体实例:参考demo工程里面的JXCategoryTitleAttributeView
JXCategoryIndicatorView、JXCategoryIndicatorCell、JXCategoryIndicatorCellModel
,就像JXCategoryTitleView、JXCategoryTitleCell、JXCategoryTitleCellModel
那样去做;JXCategoryTitleImageView系列、JXCategoryTitleAttributeView系列
那样去做;首先,在viewDidAppear加上下面代码:
- (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; self.navigationController.interactivePopGestureRecognizer.enabled = (self.categoryView.selectedIndex == 0); }
#pragma mark - JXCategoryViewDelegate - (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index { self.navigationController.interactivePopGestureRecognizer.enabled = (index == 0); }
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer { return YES; }
#pragma mark - JXCategoryViewDelegate - (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index { self.navigationController.interactivePopGestureRecognizer.enabled = (index == 0); }
#pragma mark - JXCategoryViewDelegate - (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index { [self.scrollView setContentOffset:CGPointMake(self.scrollView.bounds.size.width*index, 0) animated:YES]; }
该仓库保持随时更新,对于主流新的分类选择效果会第一时间支持。使用过程中,有任何建议或问题,可以通过以下方式联系我:
邮箱:317437084@qq.com
QQ群: 112440151
下载源码,一睹为快!JXCategoryView
日期:2018-10 浏览次数:7540
日期:2018-12 浏览次数:4621
日期:2018-07 浏览次数:5134
日期:2018-12 浏览次数:4415
日期:2018-09 浏览次数:5774
日期:2018-12 浏览次数:10194
日期:2018-11 浏览次数:5106
日期:2018-07 浏览次数:4854
日期:2018-05 浏览次数:5117
日期:2018-12 浏览次数:4582
日期:2018-10 浏览次数:5390
日期:2018-12 浏览次数:6460
日期:2018-11 浏览次数:4716
日期:2018-08 浏览次数:4867
日期:2018-11 浏览次数:12959
日期:2018-09 浏览次数:5877
日期:2018-12 浏览次数:5094
日期:2018-10 浏览次数:4438
日期:2018-11 浏览次数:4792
日期:2018-12 浏览次数:6320
日期:2018-06 浏览次数:4263
日期:2018-08 浏览次数:5712
日期:2018-10 浏览次数:4699
日期:2018-12 浏览次数:4816
日期:2018-07 浏览次数:4629
日期:2018-12 浏览次数:4802
日期:2018-06 浏览次数:4635
日期:2018-11 浏览次数:4617
日期:2018-12 浏览次数:4547
日期:2018-12 浏览次数:5528
Copyright ? 2013-2018 Tadeng NetWork Technology Co., LTD. All Rights Reserved.