發表日期:2018-08 文章編輯:小燈 瀏覽次數:2554
騰訊新聞今日頭條、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 瀏覽次數:7525
日期:2018-12 瀏覽次數:4598
日期:2018-07 瀏覽次數:5115
日期:2018-12 瀏覽次數:4402
日期:2018-09 瀏覽次數:5756
日期:2018-12 瀏覽次數:10181
日期:2018-11 瀏覽次數:5091
日期:2018-07 瀏覽次數:4845
日期:2018-05 瀏覽次數:5098
日期:2018-12 瀏覽次數:4562
日期:2018-10 瀏覽次數:5377
日期:2018-12 瀏覽次數:6438
日期:2018-11 瀏覽次數:4705
日期:2018-08 瀏覽次數:4850
日期:2018-11 瀏覽次數:12938
日期:2018-09 瀏覽次數:5858
日期:2018-12 瀏覽次數:5084
日期:2018-10 瀏覽次數:4423
日期:2018-11 瀏覽次數:4769
日期:2018-12 瀏覽次數:6299
日期:2018-06 瀏覽次數:4249
日期:2018-08 瀏覽次數:5697
日期:2018-10 瀏覽次數:4681
日期:2018-12 瀏覽次數:4792
日期:2018-07 瀏覽次數:4614
日期:2018-12 瀏覽次數:4783
日期:2018-06 瀏覽次數:4623
日期:2018-11 瀏覽次數:4603
日期:2018-12 瀏覽次數:4526
日期:2018-12 瀏覽次數:5507
Copyright ? 2013-2018 Tadeng NetWork Technology Co., LTD. All Rights Reserved.