文章来源:淘论文网   发布者: 毕业设计   浏览量: 66



还可以点击去查询以下关键词:
[类似]    [excel]    [跨行]    [定制]    [跨列]    [表格]    [类似excel跨行定制跨列表格]   

项目介绍:



上次没有传demo 附件的github 地址贴出来。这次贴出来https://github.com/conquerLust/FromLikeExcel
类似excel跨行跨列的表格
利用UICollectionView实现,开题报告,关键是自定义UICollectionViewLayoutAttributes 自定义了cell的大小来实现跨行跨列表格
   关键代码如下:

for (int section = 0; section < [self.collectionView numberOfSections]; section ++) {

        NSMutableArray *sectionAttributes = [@[] mutableCopy];

        for (NSUInteger row = 0; row < _allColumns; row++) {

            CGSize itemSize = [self.itemsSize[section][row] CGSizeValue];

            NSIndexPath *indexPath = [NSIndexPath indexPathForItem:row inSection:section];

            UICollectionViewLayoutAttributes *attributes = [UICollectionViewLayoutAttributes layoutAttributesForCellWithIndexPath:indexPath];

            attributes.frame = CGRectIntegral(CGRectMake(xOffset, yOffset, itemSize.width, itemSize.height));

            if (section == 0 && row < _lockColumn) {

                attributes.zIndex = 2015;

            } else if (section == 0 || row < _lockColumn) {

                attributes.zIndex = 2014;

            }

            if (section == 0) {

                CGRect frame = attributes.frame;

                frame.origin.y = self.collectionView.contentOffset.y;

                attributes.frame = frame;

            }


            if (row < _lockColumn) {

                CGRect frame = attributes.frame;

                float offsetX = 0;

                if (index > 0) {

                    for (int i = 0; i < row; i++) {

                        offsetX += MinmumItemWidth;

                    }

                }


                frame.origin.x = self.collectionView.contentOffset.x + offsetX;

                attributes.frame = frame;

            }


            [sectionAttributes addObject:attributes];


            xOffset = xOffset + MinmumItemWidth;

            column ++;


            if (column == _allColumns) {

                if (xOffset > contentWidth) {

                    contentWidth = xOffset;

                }


                // 重置基本变量

                column = 0;

                xOffset = 0;

                yOffset += MinmumItemHeight;

            }

        }

        [self.itemAttributes addObject:sectionAttributes];

    }


    // 获取右下角最有一个item,开题报告,确定collectionView的contentSize大小

    UICollectionViewLayoutAttributes *attributes = [[self.itemAttributes lastObject] lastObject];

    contentHeight = attributes.frame.origin.y + attributes.frame.size.height;

    _contentSize = CGSizeMake(contentWidth, contentHeight);


这里还有:


还可以点击去查询:
[类似]    [excel]    [跨行]    [定制]    [跨列]    [表格]    [类似excel跨行定制跨列表格]   

请扫码加微信 微信号:sj52abcd


下载地址: http://www.taolw.com/down/4103.docx
  • 上一篇:iOS支付输入框、集成化的支付弹框,可自定义弹框视图
  • 下一篇:iOS-基于VLCKit实现仿网易云音乐