資料介紹
軟件簡介
ZLCollectionview 為應對類似淘寶首頁,京東首頁,國美首頁等復雜布局而寫。基于UICollectionView實現,目前支持標簽布局,列布局,百分比布局,定位布局,填充式布局,瀑布流布局等。支持縱向布局和橫向布局,可以根據不同的 section 設置不同的布局,支持拖動cell,頭部懸浮,設置section背景色和自定義section背景view,向自定義背景view傳遞自定義方法。實現了電影選座等高難度的布局。
?
導入
支持cocoapod導入,最新版本 1.4.4
pod 'ZLCollectionViewFlowLayout'
注意事項:
版本1.0開始加入了橫向布局,有升級到1.0的,原來的類ZLCollectionViewFlowLayout提示找不到,請更換成ZLCollectionViewVerticalLayout即可,其余不變。如果不想升級可用 pod 'ZLCollectionViewFlowLayout','0.8.7.1'
- ZLCollectionViewVerticalLayout ==== 縱向布局
- ZLCollectionViewHorzontalLayout ==== 橫向布局(暫時先做了標簽頁布局和瀑布流,其余的后續增加)
如果遇到以下錯誤, Unable to find a specification for?ZLCollectionViewFlowLayout
?請使用pod update命令來安裝。
參數列表
可配置參數 | 類型 | 作用 |
---|---|---|
isFloor | BOOL | 寬度是否向下取整,默認為YES,該參數一般不用改 |
canDrag | BOOL | 是否允許拖動cell,默認為NO |
header_suspension | BOOL | 頭部是否懸浮,默認為NO |
layoutType | ZLLayoutType | 設置布局類型,適用于只有單一布局可省去寫代理的代碼 |
columnCount | columnCount | 在列布局中設置列數,適用于單一布局可省去寫代理的代碼 |
fixTop | CGFloat | header距離頂部的距離 |
布局名稱 | 布局類型 | 作用 |
---|---|---|
LabelLayout | 標簽頁布局 | ? |
ColumnLayout | 列布局 | 瀑布流,單行布局,等分布局 |
PercentLayout | 百分比布局 | ? |
FillLayout | 填充式布局 | ? |
AbsoluteLayout | 絕對定位布局 | ? |
用法
//在UICollectionView創建之前加入ZLCollectionViewFlowLayout - (UICollectionView*)collectionViewLabel { if (!_collectionViewLabel) { ZLCollectionViewFlowLayout *flowLayout = [[ZLCollectionViewFlowLayout alloc] init]; flowLayout.delegate = self; _collectionViewLabel = [[UICollectionView alloc]initWithFrame:self.view.bounds collectionViewLayout:flowLayout]; _collectionViewLabel.dataSource = self; _collectionViewLabel.delegate = self; _collectionViewLabel.backgroundColor = [UIColor whiteColor]; [_collectionViewLabel registerClass:[SEMyRecordLabelCell class] forCellWithReuseIdentifier:[SEMyRecordLabelCell cellIdentifier]]; [_collectionViewLabel registerClass:[SEMyRecordHeaderView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:[SEMyRecordHeaderView headerViewIdentifier]]; } return _collectionViewLabel; } //實現代理,如果不實現也可以自己直接設置self.sectionInset,self.minimumLineSpacing,self.minimumInteritemSpacing。但是這種設置不支持不同section不同數值 //指定section用的樣式。LabelLayout是標簽樣式,ClosedLayout用于tableviewcell或者瀑布流,九宮格之類的。 - (ZLLayoutType)collectionView:(UICollectionView *)collectionView layout:(ZLCollectionViewFlowLayout *)collectionViewLayout typeOfLayout:(NSInteger)section { switch (section) { case 0: return LabelLayout; case 1: case 2: return FillLayout; case 3: case 4: return AbsoluteLayout; case 5: case 6: return PercentLayout; default: return ClosedLayout; } } //如果是ClosedLayout樣式的section,必須實現該代理,指定列數 - (NSInteger)collectionView:(UICollectionView *)collectionView layout:(ZLCollectionViewFlowLayout*)collectionViewLayout columnCountOfSection:(NSInteger)section { switch (section) { case 7: return 4; case 8: return 2; case 9: return 1; default: return 0; } } //如果是百分比布局必須實現該代理,設置每個item的百分比,如果沒實現默認比例為1 - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(ZLCollectionViewFlowLayout*)collectionViewLayout percentOfRow:(NSIndexPath*)indexPath; { switch (indexPath.section) { case 5: { switch (indexPath.item) { case 0: return 1.0/3; case 1: return 2.0/3; case 2: return 1.0/3; case 3: return 1.0/3; case 4: return 1.0/3; case 5: return 1.0/4; case 6: return 1.0/4; case 7: return 1.0/2; case 8: return 3.0/5; case 9: return 2.0/5; default: break; } } case 6: { if (indexPath.item % 2==0) { return 3.0/4; } else { return 1.0/4; } } default: return 1; } } //如果是絕對定位布局必須是否該代理,設置每個item的frame - (CGRect)collectionView:(UICollectionView *)collectionView layout:(ZLCollectionViewFlowLayout*)collectionViewLayout rectOfItem:(NSIndexPath*)indexPath { switch (indexPath.section) { case 3: { CGFloat width = (collectionView.frame.size.width-200)/2; CGFloat height = width; switch (indexPath.item) { case 0: return CGRectMake(0, 0, width, height); case 1: return CGRectMake(width, 0, width, height); case 2: return CGRectMake(0, height, width, height); case 3: return CGRectMake(width, height, width, height); case 4: return CGRectMake(width/2, height/2, width, height); default: return CGRectZero; } } break; case 4: { switch (indexPath.item) { case 0: return CGRectMake((collectionView.frame.size.width-20)/2-100, 0, 200, 30); default: { NSInteger column = (collectionView.frame.size.width-20)/30; return CGRectMake(((indexPath.item-1)%column)*30, 100+((indexPath.item-1)/column)*30, 20, 20); } } } break; default: return CGRectZero; } return CGRectZero; }
?
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉
- labview超快自定义控件制作和普通自定义控件制作13次下载
- labview自定义控件18次下载
- 自定义视图组件教程案例14次下载
- Labview自定义右键快捷菜单功能实用小技巧27次下载
- 精美的TF自定义控件源文件合集31次下载
- 串口屏LUA教程10-自定义串口指令16次下载
- Xilinx基本自定义OpenRISC系统硬件教程93次下载
- 如何在LabVIEW中实现自定义控件48次下载
- LCD1602自定义显示字符及汉字85次下载
- PDH网管盘 自定义字节0次下载
- JAVA教程之自定义光标7次下载
- DOS下自定义时间重启6次下载
- 1602自定义字符1次下载
- 自定义函数测试学习工程5次下载
- matlab自定义函数调用的方法88次下载
- 如何添加自定义单板364次阅读
- 如何快速创建用户自定义Board和App工程289次阅读
- TSMaster 自定义 LIN 调度表编程指导911次阅读
- 基于YOLOv8实现自定义姿态评估模型训练3133次阅读
- 博途用户自定义库的使用1336次阅读
- 添加自定义属性控制fridaserver启动和停止2012次阅读
- 什么是自定义序列1353次阅读
- 自定义特性能做什么?950次阅读
- FreeRTOS|自定义裁剪1675次阅读
- 如何自定义函数或局部脚本1606次阅读
- 如何在Vivado中更改自定义的Interface3200次阅读
- 三种自定义弹窗UI组件封装的实现3368次阅读
- 如何给EOS账号设置自定义权限1595次阅读
- erlang如何自定义_ERLANG环境搭建1581次阅读
- LCD1602自定义点阵字符详解13706次阅读
下載排行
本周
- 1山景DSP芯片AP8248A2數據手冊
- 1.06 MB | 532次下載 | 免費
- 2RK3399完整板原理圖(支持平板,盒子VR)
- 3.28 MB | 339次下載 | 免費
- 3TC358743XBG評估板參考手冊
- 1.36 MB | 330次下載 | 免費
- 4DFM軟件使用教程
- 0.84 MB | 295次下載 | 免費
- 5元宇宙深度解析—未來的未來-風口還是泡沫
- 6.40 MB | 227次下載 | 免費
- 6迪文DGUS開發指南
- 31.67 MB | 194次下載 | 免費
- 7元宇宙底層硬件系列報告
- 13.42 MB | 182次下載 | 免費
- 8FP5207XR-G1中文應用手冊
- 1.09 MB | 178次下載 | 免費
本月
- 1OrCAD10.5下載OrCAD10.5中文版軟件
- 0.00 MB | 234315次下載 | 免費
- 2555集成電路應用800例(新編版)
- 0.00 MB | 33566次下載 | 免費
- 3接口電路圖大全
- 未知 | 30323次下載 | 免費
- 4開關電源設計實例指南
- 未知 | 21549次下載 | 免費
- 5電氣工程師手冊免費下載(新編第二版pdf電子書)
- 0.00 MB | 15349次下載 | 免費
- 6數字電路基礎pdf(下載)
- 未知 | 13750次下載 | 免費
- 7電子制作實例集錦 下載
- 未知 | 8113次下載 | 免費
- 8《LED驅動電路設計》 溫德爾著
- 0.00 MB | 6656次下載 | 免費
總榜
- 1matlab軟件下載入口
- 未知 | 935054次下載 | 免費
- 2protel99se軟件下載(可英文版轉中文版)
- 78.1 MB | 537798次下載 | 免費
- 3MATLAB 7.1 下載 (含軟件介紹)
- 未知 | 420027次下載 | 免費
- 4OrCAD10.5下載OrCAD10.5中文版軟件
- 0.00 MB | 234315次下載 | 免費
- 5Altium DXP2002下載入口
- 未知 | 233046次下載 | 免費
- 6電路仿真軟件multisim 10.0免費下載
- 340992 | 191187次下載 | 免費
- 7十天學會AVR單片機與C語言視頻教程 下載
- 158M | 183279次下載 | 免費
- 8proe5.0野火版下載(中文版免費下載)
- 未知 | 138040次下載 | 免費
評論