UICollectionViewFlowLayout

2018/11/20 posted in  iOS

可以重写方法

  • (nullable NSArray<__kindof UICollectionViewLayoutAttributes *> *)layoutAttributesForElementsInRect:(CGRect)rect;

给每个 cell 重写布局

另外还有下面这个方法在 view 的位置改变的时候实时调用上一个方法

  • (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds; // return YES to cause the collection view to requery the layout for geometry information

UIViewPropertyAnimator

动画除了[UIView animation...]
还可以使用UIView中的这个属性实现

创建一个 animator跟一个 block 实现具体的动画效果
然后启动 animator

添加Blur

let blurEffect = UIBlurEffect(style:.regular)

let visualEffectView = UIViewEffectView(effct:blurEffect)

self.addSubview(visualEffectView)

然后布局visualEffectView

蒙版的效果就有了