為您解碼網(wǎng)站建設(shè)的點(diǎn)點(diǎn)滴滴
發(fā)表日期:2018-08 文章編輯:小燈 瀏覽次數(shù):2631
騰訊新聞今日頭條、QQ音樂(lè)、網(wǎng)易云音樂(lè)、京東、愛(ài)奇藝、淘寶、天貓、 、微博等所有主流APP分類切換滾動(dòng)視圖
與其他的同類三方庫(kù)對(duì)比的優(yōu)點(diǎn):
下載源碼,一睹為快!JXCategoryView
說(shuō)明 | Gif |
---|---|
指示器LineView | ![]() |
指示器LineView京東風(fēng)格 | ![]() |
指示器LineView愛(ài)奇藝風(fēng)格 | ![]() |
指示器EllipseLayer | ![]() |
指示器EllipseLayer遮罩 | ![]() |
指示器EllipseLayer遮罩 (陰影) | ![]() |
指示器ImageView(小船) | ![]() |
指示器滾動(dòng)效果(足球) | ![]() |
QQ黏性紅點(diǎn) | ![]() |
三角形底部 | ![]() |
三角形頂部 | ![]() |
文字遮罩(無(wú)背景視圖) | ![]() |
背景指示圖 | ![]() |
矩形指示圖 | ![]() |
混合使用 | ![]() |
自定義Indicator示例-點(diǎn)線 | ![]() |
說(shuō)明 | Gif |
---|---|
顏色漸變 | ![]() |
大小縮放 | ![]() |
分割線 | ![]() |
TitleImage_Top | ![]() |
TitleImage_Left | ![]() |
TitleImage_Bottom | ![]() |
TitleImage_Right | ![]() |
TitleImage_OnlyImage | ![]() |
圖文混用 | ![]() |
自定義-數(shù)字 | ![]() |
自定義cell-紅點(diǎn) | ![]() |
自定義cell-背景色漸變 | ![]() |
騰訊視頻效果 | ![]() |
自定義cell示例-多行+富文本 | ![]() |
說(shuō)明 | Gif |
---|---|
SegmentedControl | ![]() |
導(dǎo)航欄使用 | ![]() |
個(gè)人主頁(yè)(上下左右滾動(dòng)、header懸浮) | ![]() |
嵌套使用 | ![]() |
垂直列表滾動(dòng) 高仿騰訊視頻 (背景色異常是錄屏軟件bug | ![]() |
數(shù)據(jù)源刷新&列表數(shù)據(jù)加載 示例 | ![]() |
Clone代碼,把Sources文件夾拖入項(xiàng)目,#import "JXCategoryView.h",就可以使用了;
target '<Your Target Name>' do pod 'JXCategoryView' end
JXCategoryIndicatorProtocol
協(xié)議,就可以實(shí)現(xiàn)你的指示器效果。參考:JXCategoryIndicatorLineView;VerticalListViewController
,未做功能封裝,參考里面的代碼做,多注意注釋,就可以實(shí)現(xiàn)了。通過(guò)將指示器的行為抽象出來(lái),再通過(guò)JXCategoryIndicatorProtocol
協(xié)議進(jìn)行約束。這樣指示器效果就可以無(wú)限擴(kuò)展,為所欲為的添加指示器了,不再受上一個(gè)版本繼承的束縛了。更多POP內(nèi)容,推薦喵神的文章面向協(xié)議編程與 Cocoa 的邂逅
屬性 | 說(shuō)明 |
---|---|
defaultSelectedIndex | 默認(rèn)選中的index,用于初始化時(shí)指定選中某個(gè)index |
selectedIndex | 只讀屬性,當(dāng)前選中的index |
cellWidth | cell的寬度,默認(rèn):JXCategoryViewAutomaticDimension |
cellSpacing | cell之間的間距,默認(rèn)20 |
cellWidthIncrement | cell寬度的補(bǔ)償值,默認(rèn)0 |
averageCellWidthEnabled | 當(dāng)cell內(nèi)容總寬度小于JXCategoryBaseView的寬度,是否將cellWidth均分。默認(rèn)為YES。 |
contentScrollView | 需要關(guān)聯(lián)的contentScrollView,內(nèi)部監(jiān)聽(tīng)contentOffset |
屬性 | 說(shuō)明 |
---|---|
titleColor | titleLabel未選中顏色 默認(rèn):[UIColor blackColor] |
titleSelectedColor | titleLabel選中顏色 默認(rèn):[UIColor redColor] |
titleFont | titleLabel的字體 默認(rèn):[UIFont systemFontOfSize:15] |
titleColorGradientEnabled | title的顏色是否漸變過(guò)渡 默認(rèn):NO |
titleLabelMaskEnabled | titleLabel是否遮罩過(guò)濾 默認(rèn):NO |
titleLabelZoomEnabled | titleLabel是否縮放 默認(rèn):NO |
titleLabelZoomScale | citleLabel縮放比例 默認(rèn):1.2 |
imageZoomEnabled | imageView是否縮放 默認(rèn):NO |
imageZoomScale | imageView縮放比例 默認(rèn):1.2 |
separatorLineShowEnabled | cell分割線是否展示 默認(rèn):NO (顏色、寬高可以設(shè)置) |
JXCategoryTitleImageType | 圖片所在位置:上面、左邊、下面、右邊 默認(rèn):左邊 |
屬性 | 說(shuō)明 |
---|---|
JXCategoryIndicatorComponentView.componentPosition | 指示器的位置 默認(rèn):Bottom |
JXCategoryIndicatorComponentView.scrollEnabled | 手勢(shì)滾動(dòng)、點(diǎn)擊切換的時(shí)候,是否允許滾動(dòng),默認(rèn)YES |
JXCategoryIndicatorLineView.lineStyle | 普通、京東、愛(ài)奇藝效果 默認(rèn):Normal |
JXCategoryIndicatorLineView.lineScrollOffsetX | 愛(ài)奇藝效果專用,line滾動(dòng)時(shí)x的偏移量,默認(rèn)為10; |
JXCategoryIndicatorLineView.indicatorLineWidth | 默認(rèn)JXCategoryViewAutomaticDimension(與cellWidth相等) |
JXCategoryIndicatorLineView.indicatorLineViewHeight | 默認(rèn):3 |
JXCategoryIndicatorLineView.indicatorLineViewCornerRadius | 默認(rèn)JXCategoryViewAutomaticDimension (等于self.indicatorLineViewHeight/2) |
JXCategoryIndicatorLineView.indicatorLineViewColor | 默認(rèn)為[UIColor redColor] |
JXCategoryIndicatorTriangleView.triangleViewSize | 默認(rèn):CGSizeMake(14, 10) |
JXCategoryIndicatorTriangleView.triangleViewColor | 默認(rèn)為[UIColor redColor] |
JXCategoryIndicatorImageView.indicatorImageView | 設(shè)置image |
JXCategoryIndicatorImageView.indicatorImageViewRollEnabled | 是否允許滾動(dòng),默認(rèn):NO |
JXCategoryIndicatorImageView.indicatorImageViewSize | 默認(rèn):CGSizeMake(30, 20) |
JXCategoryIndicatorBackgroundView.backgroundViewWidth | 默認(rèn)JXCategoryViewAutomaticDimension(與cellWidth相等) |
JXCategoryIndicatorBackgroundView.backgroundViewWidthIncrement | 寬度增量補(bǔ)償,因?yàn)閎ackgroundEllipseLayer一般會(huì)比實(shí)際內(nèi)容大一些。默認(rèn)10 |
JXCategoryIndicatorBackgroundView.backgroundViewHeight | 默認(rèn)JXCategoryViewAutomaticDimension(與cell高度相等) |
JXCategoryIndicatorBackgroundView.backgroundViewCornerRadius | 默認(rèn)JXCategoryViewAutomaticDimension(即backgroundViewHeight/2) |
JXCategoryIndicatorBackgroundView.backgroundViewColor | 默認(rèn)為[UIColor redColor] |
JXCategoryIndicatorBallView.ballViewSize | 默認(rèn):CGSizeMake(15, 15) |
JXCategoryIndicatorBallView.ballScrollOffsetX | 小紅點(diǎn)的偏移量 默認(rèn):20 |
JXCategoryIndicatorBallView.ballViewColor | 默認(rèn)為[UIColor redColor] |
可以多個(gè)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的初始化細(xì)節(jié)參考源碼。 self.categoryView.contentScrollView = self.scrollView; [self.view addSubview:self.categoryView];
- (void)reloadCell:(NSUInteger)index
reloadData
方法刷新?tīng)顟B(tài)。倉(cāng)庫(kù)自帶:JXCategoryIndicatorLineView、JXCategoryIndicatorTriangleView、JXCategoryIndicatorImageView、JXCategoryIndicatorBackgroundView、JXCategoryIndicatorBallView
主要實(shí)現(xiàn)的方法:
JXCategoryIndicatorProtocol
協(xié)議;- (void)jx_refreshState:(CGRect)selectedCellFrame
初始化或reloadData,重置狀態(tài);- (void)jx_contentScrollViewDidScrollWithLeftCellFrame:(CGRect)leftCellFrame rightCellFrame:(CGRect)rightCellFrame selectedPosition:(JXCategoryCellClickedPosition)selectedPosition percent:(CGFloat)percent
contentScrollView在進(jìn)行手勢(shì)滑動(dòng)時(shí),處理指示器跟隨手勢(shì)變化UI邏輯;- (void)jx_selectedCell:(CGRect)cellFrame clickedRelativePosition:(JXCategoryCellClickedPosition)clickedRelativePosition
根據(jù)選中的某個(gè)cell,處理過(guò)渡效果;具體實(shí)例:參考demo工程里面的JXCategoryIndicatorDotLineView
倉(cāng)庫(kù)自帶:JXCategoryTitleView、JXCategoryTitleImageView、JXCategoryNumberView、JXCategoryDotView、JXCategoryImageView
主要實(shí)現(xiàn)的方法:
- (Class)preferredCellClass
返回自定義的cell;- (void)refreshDataSource
刷新數(shù)據(jù)源,使用自定義的cellModel;- (void)refreshCellModel:(JXCategoryBaseCellModel *)cellModel index:(NSInteger)index
初始化、reloadData時(shí)對(duì)數(shù)據(jù)源重置;- (CGFloat)preferredCellWidthAtIndex:(NSInteger)index
根據(jù)cell的內(nèi)容返回對(duì)應(yīng)的寬度;- (void)refreshSelectedCellModel:(JXCategoryBaseCellModel *)selectedCellModel unselectedCellModel:(JXCategoryBaseCellModel *)unselectedCellModel
cell選中時(shí)進(jìn)行狀態(tài)刷新;- (void)refreshLeftCellModel:(JXCategoryBaseCellModel *)leftCellModel rightCellModel:(JXCategoryBaseCellModel *)rightCellModel ratio:(CGFloat)ratio
cell左右滾動(dòng)切換的時(shí)候,進(jìn)行狀態(tài)刷新;具體實(shí)例:參考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]; }
該倉(cāng)庫(kù)保持隨時(shí)更新,對(duì)于主流新的分類選擇效果會(huì)第一時(shí)間支持。使用過(guò)程中,有任何建議或問(wèn)題,可以通過(guò)以下方式聯(lián)系我:
郵箱:317437084@qq.com
QQ群: 112440151
下載源碼,一睹為快!JXCategoryView