• Stars
    star
    6,026
  • Rank 6,455 (Top 0.2 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created about 6 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A powerful and easy to use category view (segmentedcontrol, segmentview, pagingview, pagerview, pagecontrol) (腾讯新闻、今日头条、QQ音乐、网易云音乐、京东、爱奇艺、腾讯视频、淘宝、天猫、简书、微博等所有主流APP分类切换滚动视图)

platform languages cocoapods support

A powerful and easy to use category view (segmentedcontrol, segmentview, pagingview, pagerview, pagecontrol) (腾讯新闻、今日头条、QQ 音乐、网易云音乐、京东、爱奇艺、腾讯视频、淘宝、天猫、简书、微博等所有主流 APP 分类切换滚动视图)

与其他的同类三方库对比的优点:

  • 使用协议封装指示器逻辑,可以随心所欲地自定义指示器效果;
  • 提供更加全面丰富、高度自定义的效果;
  • 使用子类化管理 cell 样式,逻辑更清晰,扩展更简单;
  • 高度封装列表容器,使用便捷,完美支持列表的生命周期调用;

Swift版本

如果你在找 Swift 版本,请点击查看 JXSegmentedView

效果预览

指示器效果预览

说明 Gif
LineView
LineView延长
LineView延长+偏移
LineView🌈彩虹风格
DotLineView点线效果
BallView QQ黏性红点
TriangleView 三角形底部
TriangleView 三角形顶部
BackgroundView椭圆形
BackgroundView椭圆形+阴影
BackgroundView长方形
BackgroundView遮罩有背景
BackgroundView遮罩无背景
BackgroundView渐变色
ImageView底部(小船)
ImageView背景(最佳男歌手)
ImageView滚动效果(足球)
混合使用

以下均支持上下位置切换: JXCategoryIndicatorLineViewJXCategoryIndicatorImageViewJXCategoryIndicatorBallViewJXCategoryIndicatorTriangleView

Cell样式效果预览

说明 Gif
颜色渐变
大小缩放
大小缩放+底部锚点
大小缩放+顶部锚点
大小缩放+字体粗细
大小缩放+点击动画
大小缩放+cell宽度缩放
TitleImage_Top
TitleImage_Left
TitleImage_Bottom
TitleImage_Right
cell图文混用
Image
数字
红点
多行文本
多行富文本
Cell背景色渐变
分割线

特殊效果预览

说明 Gif
数据源过少
averageCellSpacingEnabled默认为YES
数据源过少
averageCellSpacingEnabled为NO
SegmentedControl
参考SegmentedControlViewController
导航栏使用
参考NaviSegmentedControlViewController
嵌套使用
参考NestViewController
个人主页(上下左右滚动、header悬浮)
参考PagingViewController
更多样式请点击查看JXPagingView库
垂直列表滚动
参考VerticalListViewController
高仿腾讯视频
支持UITableView,参考VerticalListTableViewController
(背景色异常是录屏软件bug)
垂直缩放(仿网易圈圈、脉脉首页)
参考ScrollZoomViewController
数据源刷新&列表数据加载
参考LoadDataListContainerViewController
上下滚动隐藏导航栏
京东首页-滚动渐变变小

自定义效果预览

收录来自其他使用者的自定义示例,这些自定义类只在 Demo 项目里面,Pod 库并没有这些文件。所以,如果你需要使用这些自定义效果,请通过文件导入的方式。

目的:

  • 参考学习如何自定义;
  • 直接修改自定义示例类以快速实现自己的需求。

欢迎提 PullRequest 进行收录你的自定义效果。

说明 Gif
Spring动画指示器
富文本数量cell
左右对齐指示器
秒杀时间线cell
京东商品排序cell
title背景块cell

要求

  • iOS 9.0+
  • Xcode 9+
  • Objective-C

安装

手动

Clone 代码,把 Sources 文件夹拖入项目,#import "JXCategoryView.h" 就可以使用了。

CocoaPods

target '<Your Target Name>' do
    pod 'JXCategoryView'
end

先执行 pod repo update,再执行 pod install

结构图

使用

JXCategoryTitleView 使用示例

  1. 初始化 JXCategoryTitleView
self.categoryView = [[JXCategoryTitleView alloc] initWithFrame:CGRectMake(0, 0, WindowsSize.width, 50)];
self.categoryView.delegate = self;
[self.view addSubview:self.categoryView];
  1. 配置 JXCategoryTitleView 的属性:
self.categoryView.titles = @[@"螃蟹", @"麻辣小龙虾", @"苹果"...];
self.categoryView.titleColorGradientEnabled = YES;
  1. 添加指示器:
JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
lineView.indicatorColor = [UIColor redColor];
lineView.indicatorWidth = JXCategoryViewAutomaticDimension;
self.categoryView.indicators = @[lineView];
  1. 实现 JXCategoryViewDelegate 代理(可选)
// 点击选中或者滚动选中都会调用该方法。适用于只关心选中事件,不关心具体是点击还是滚动选中的。
- (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index;

// 点击选中的情况才会调用该方法
- (void)categoryView:(JXCategoryBaseView *)categoryView didClickSelectedItemAtIndex:(NSInteger)index;

// 滚动选中的情况才会调用该方法
- (void)categoryView:(JXCategoryBaseView *)categoryView didScrollSelectedItemAtIndex:(NSInteger)index;

// 正在滚动中的回调
- (void)categoryView:(JXCategoryBaseView *)categoryView scrollingFromLeftIndex:(NSInteger)leftIndex toRightIndex:(NSInteger)rightIndex ratio:(CGFloat)ratio;

列表容器使用示例

JXCategoryListContainerView 封装类使用示例

JXCategoryListContainerView 是对列表视图高度封装的类,具有以下优点:

  • 相对于直接使用 UIScrollView 自定义,封装度高、代码集中、使用简单;
  • 列表懒加载:当显示某个列表的时候,才进行列表初始化。而不是一次性加载全部列表,性能更优;
  • 支持列表的 willAppeardidAppearwillDisappeardidDisappear 生命周期方法调用;
  1. 初始化 JXCategoryListContainerView 并关联到 categoryView
self.listContainerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self];
[self.view addSubview:self.listContainerView];
// 关联到 categoryView
self.categoryView.listContainer = self.listContainerView;
  1. 实现 JXCategoryListContainerViewDelegate 代理方法:
// 返回列表的数量
- (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView {
    return self.titles.count;
}
// 根据下标 index 返回对应遵守并实现 `JXCategoryListContentViewDelegate` 协议的列表实例
- (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index {
    return [[ListViewController alloc] init];
}
  1. 列表实现 JXCategoryListContentViewDelegate 代理方法 不管列表是 UIView 还是 UIViewController 都可以,提高使用灵活性,更便于现有的业务接入。
// 返回列表视图
// 如果列表是 VC,就返回 VC.view
// 如果列表是 View,就返回 View 自己
- (UIView *)listView {
    return self.view;
}

具体点击 LoadDataListContainerViewController 查看源代码了解

直接使用 UIScrollView 自定义

因为代码量较多且分散,所有不推荐使用该方法。要正确使用需要注意的地方比较多,尤其对于刚接触 iOS 的同学来说不太友好。

不直接贴代码了,具体点击 LoadDataListCustomViewController 查看源代码了解。

常见问题和答案

❗️❗️❗️这里面包含了许多常见问题和答案,使用之前请务必浏览此文档,或者遇到问题先看此文档❗️❗️❗️

常见问题和答案总文档

指示器样式自定义

  • 需要继承 JXCategoryIndicatorProtocol 协议,点击参看 JXCategoryIndicatorProtocol
  • 提供了继承 JXCategoryIndicatorProtocol 协议的基类 JXCategoryIndicatorComponentView,里面提供了许多基础属性。点击参看 JXCategoryIndicatorComponentView
  • 自定义指示器,请参考已实现的指示器视图,多尝试、多思考,再有问题请提 Issue 或加入反馈 QQ 群。

Cell 自定义

  • 任何子类化需求,view、cell、cellModel 三个都要子类化,即使某个子类 cell 什么事情都不做。用于维护继承链,以免以后子类化都不知道要继承谁了;
  • 如果你想完全自定义 cell 里面的内容,那就继承 JXCategoryIndicatorViewJXCategoryIndicatorCell、JXCategoryIndicatorCellModel,就像JXCategoryTitleViewJXCategoryTitleCell、JXCategoryTitleCellModel那样去做;
  • 如果你只是在父类进行一些微调,那就继承目标 view、cell、cellModel,对 cell 原有控件微调、或者加入新的控件皆可。就像 JXCategoryTitleImageView 系列、JXCategoryTitleAttributeView 系列那样去做;
  • Cell 自定义,请参考已实现的 cell 样式,多尝试、多思考,再有问题请提 Issue 或加入反馈 QQ 群

常用属性说明

常用属性说明文档地址

更新记录

  • 2018.8.21 发布1.0.0版本,更新内容:使用POP(面向协议编程)重构指示器视图;迁移指南
  • 2018.8.22 发布1.0.1版本,更新内容:删除zoomEnabled,新增titleLabelZoomEnabled、imageZoomEnabled;
  • 2018.8.23 发布1.0.2版本,更新内容:添加cellWidthZoomEnabled实现腾讯视频效果;
  • 2018.8.24 发布1.0.3版本,更新内容:添加垂直列表滚动效果、指示器添加verticalMargin属性、JXCategoryViewDelegate代理方法优化;
  • 2018.9.4 发布1.0.4版本,更新内容:修复bug、添加cell图文混用示例;
  • 2018.12.19 发布1.1.7版本,更新内容:添加JXCategoryListContainerView,高度封装列表逻辑,支持懒加载列表,提升初始化性能;
  • 2019.1.24 发布1.2.2版本,更新内容:非兼容更新接口- (BOOL)selectCellAtIndex:(NSInteger)index selectedType:(JXCategoryCellSelectedType)selectedType,自定义有用到该接口的请及时更新。
  • 2019.6.21 发布1.3.13版本,更新内容:将JXCategoryListCollectionContainerView.dataSource移动到m实现文件,添加- (instancetype)initWithDataSource:(id<JXCategoryListCollectionContainerViewDataSource>)dataSource初始化方法。
  • 2019.7.20 发布1.3.16版本,删除代理方法- (void)categoryView:(JXCategoryBaseView *)categoryView didClickedItemContentScrollViewTransitionToIndex:(NSInteger)index;,请使用contentScrollViewClickTransitionAnimationEnabled属性。JXCategoryTitleVerticalZoomView进行了重构,内容左边距只需要使用contentEdgeLeft属性即可。
  • 2019.9.11 发布1.4.0版本,删除一波被标记为弃用的属性和方法;完善列表的生命周期方法的调用;JXCategoryListCollectionContainerView类新增和必须要调用- (void)scrollingFromLeftIndex:(NSInteger)leftIndex toRightIndex:(NSInteger)rightIndex ratio:(CGFloat)ratio selectedIndex:(NSInteger)selectedIndex- (void)didClickSelectedItemAtIndex:(NSInteger)index两个方法。
  • 2019.9.19 发布1.5.0版本,重构列表容器,具体修改请参考1.5.0版本迁移指南

补充

如果刚开始使用JXCategoryView,当开发过程中需要支持某种特性时,请务必先搜索使用文档或者源代码。确认是否已经实现支持了想要的特性。请别不要文档和源代码都没有看,就直接提问,这对于大家都是一种时间浪费。如果没有支持想要的特性,欢迎提Issue讨论,或者自己实现提一个PullRequest。

该仓库保持随时更新,对于主流新的分类选择效果会第一时间支持。使用过程中,有任何建议或问题,可以通过以下方式联系我:
邮箱:[email protected]
QQ群: 112440473

喜欢就star❤️一下吧

License

JXCategoryView is released under the MIT license.

More Repositories

1

JXPagingView

类似微博主页、简书主页等效果。多页面嵌套,既可以上下滑动,也可以左右滑动切换页面。支持HeaderView悬浮、支持下拉刷新、上拉加载更多。
Objective-C
2,824
star
2

JXSegmentedView

A powerful and easy to use segmented view (segmentedcontrol, pagingview, pagerview, pagecontrol, categoryview) (腾讯新闻、今日头条、QQ音乐、网易云音乐、京东、爱奇艺、腾讯视频、淘宝、天猫、简书、微博等所有主流APP分类切换滚动视图)
Swift
2,596
star
3

JXPageListView

高仿闲鱼、转转、京东、中央天气预报等主流APP列表底部分页滚动视图
Objective-C
421
star
4

JXMarqueeView

A powerful and easy to use marquee view.
Swift
365
star
5

JXBottomSheetView

A useful and gesture interaction BottomSheetView!
Swift
256
star
6

JXTheme

A powerful and lightweight and customization theme/skin library for iOS 9+ in swift. 主题、换肤、暗黑模式
Swift
243
star
7

JXPatternLock

An easy-to-use, powerful, customizable pattern lock view in swift. 图形解锁/手势解锁 / 手势密码 / 图案密码 / 九宫格密码
Swift
219
star
8

JXMovableCellTableView

The custom tableView which can start moving the cell with a long press gesture.
Objective-C
188
star
9

JXPopupView

一个轻量级的自定义视图弹出框架
Swift
139
star
10

StackUI

StackUI just like SwiftUI
Swift
117
star
11

JXScratchView

一个万能的刮刮乐控件。无论是UILabel、UIImageView,还是自定义视图,只要是UIView都可以用来刮。代码简单,功能强大,你值得拥有!
Swift
111
star
12

JXWeChatFloatView

高仿微信文章悬浮球
Swift
100
star
13

JXBottomSheetTableView

A highly packaged, easy to use custom bottom sheet UITableView.
Swift
48
star
14

JXExcel

一个轻量级的表视图
Swift
31
star
15

JXTableViewZoomHeaderImageView

一般app的个人资料页面都会有个头图,并且随着上下滚动的时候,图片有个移动和缩放的效果。
Objective-C
29
star
16

ModelAdapter

Simple JSON Object mapping and SQLite3 written in Swift
Swift
26
star
17

JXCaptain

像美国队长一样威猛的应用调试工具箱!
Swift
22
star
18

JXFileBrowserController

The debug sandbox browser for sharing.
Swift
22
star
19

JXGradientKit

常用控件背景渐变色Kit
Swift
19
star
20

JXLayerAutoLayout

优雅的实现CALayer AutoLayout
Objective-C
19
star
21

SQLiteValueExtension

SQLiteValueExtension for SQLite.swift
Swift
14
star
22

JXParallaxCell

用于滚动scrollview的时候,cell中的图片,或者其他控件,有一个视差滚动的效果
Objective-C
14
star
23

JXTransition

自定义转场动画
Objective-C
11
star
24

JXBorderCellll

一个有边框的基类cell
Objective-C
11
star
25

JXInterview

Interview for iOSer
10
star
26

XPackage

自己常用的一些工具
Objective-C
4
star
27

30DaysChallenge

There may be a miracle happen if you insist 30 days challenge!
Objective-C
3
star
28

JXExampleImages

示例图片资源
2
star
29

JXKit

JXKit for iOS
Swift
1
star
30

OnePiece

Swift
1
star
31

JXRomanticAlbum

谁说程序员不浪漫?我们可以用代码表白!Who says programmers aren't romantic? We can use the code to express love!
Swift
1
star