zoukankan      html  css  js  c++  java
  • 自定义UICollectionViewFlowLayout

    //1.实现
    -(void)prepareLayout{
        //(目的:做一些初始化;用来做布局的初始化操作(不建议在init方法里面做布局的初始化操作))
    }
     
    //2.实现
    - (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect{
        //(目的:拿出它计算好的布局属性来做一个微调,实现cell不断变大变小)
            NSArray *array =[super layoutAttributesForElementsInRect:rect] ;
            for (UICollectionViewLayoutAttributes *attrs in array) {
                 //更改attrs就可以更改frame,bounds等属性
            }
            return array;
    }
     
    //3.实现
    - (CGPoint)targetContentOffsetForProposedContentOffset:(CGPoint)proposedContentOffset withScrollingVelocity:(CGPoint)velocity{
        //(目的:当我们手一松开,它最终停止滚动的时候,应该去在哪.它决定了collectionView停止滚动时候的偏移量)
    }
     
    //4.实现
    - (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds{
        //(只要滑动就会重新刷新,就会调用prepareLayout和layoutAttributesForElementsInRect方法)
    }
  • 相关阅读:
    centos添加图形桌面
    centos 复制并重命名文件
    山东省第八届ACM程序设计大赛总结
    RMQ
    图的深度优先搜索
    ACM知识点清单
    优先队列(priority_queue)
    Contest Print Server
    k8s之证书签发(二)
    k8s环境之bind 9 (一)
  • 原文地址:https://www.cnblogs.com/cfl911014/p/7325676.html
Copyright © 2011-2022 走看看